r/learnjava • u/wildmutt4349 • 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
6
u/CleverBunnyThief Oct 19 '23
It's just a warning from the IDE. It's letting you know you have a variable that is not used. It can be annoying if just declared it and will be using the variable later on in your code but haven't done so yet.
In practice you should remove unused variables.
Fun fact: Go doesn't allow unused variables. The your code won't compile if there are unused variables in your code.