r/learnjava • • Oct 19 '23

Declaring a variable in java.

Hey guys, whenever I declare a variable "a" in java it gets underlined by a yellow squiggle, and shows "the value of local variable a is not used. Is it normal in java, because earlier I used to code in c++ and this is my first time encountering a yellow squiggle.

4 Upvotes

5 comments sorted by

View all comments

2

u/Ok-Comfortable7967 Oct 19 '23

Yeah it's just your development environment letting you know that you declared a variable but then never used it in your code. It keeps you from having wasted variables that maybe you declared initially and then never ended up using. As soon as you add it into your code somewhere then that squiggly line will go away. Also, if you finish your entire program and look back and notice several variables have squiggly lines then you can probably just delete them because you did not end up using them anywhere. Most development environments also do this with imports. So if you imported stuff that you never use anywhere in your code it will let you know so you can remove the imports.

1

u/wildmutt4349 Oct 19 '23

Got it, thanks for the explanation.