+ 2

When I write string name, it shows that local variable value not used even if I give it a value.

19th Jun 2017, 7:18 AM
Rahul Siloniya
Rahul Siloniya - avatar
6 Answers
+ 3
I think you are confused with class variable and method variable, it will be good idea if you show us your code.
19th Jun 2017, 7:27 AM
Loai Hazima
Loai Hazima - avatar
+ 2
Not use is different from uninitialized, try to display it or something
19th Jun 2017, 8:15 AM
Baptiste E. Prunier
Baptiste E. Prunier - avatar
+ 2
I wrote { class siloniya public static void main(String[ ] args){ String name ="Rahul"; } }
19th Jun 2017, 12:23 PM
Rahul Siloniya
Rahul Siloniya - avatar
+ 2
And when I wrote this it said, "local variable is not used."
19th Jun 2017, 12:24 PM
Rahul Siloniya
Rahul Siloniya - avatar
+ 2
yes it is local variable inside the main method , its just a warning and not an error, it warns you that you declared a variable but never used it.
19th Jun 2017, 12:26 PM
Loai Hazima
Loai Hazima - avatar
+ 2
But when I run it, it doesn't output anything.
19th Jun 2017, 12:27 PM
Rahul Siloniya
Rahul Siloniya - avatar