Since inside static methods we:
- Cannot make static reference to a non-static field
- Then a local variable in a static method SHOULD be static as well.
But according to this answer here: Are local variables in static methods also static?
- Local variables in static methods are just local variables in a static method. They're not static, and they're not special in any way.
There is a conflict between my deduction (2) and the statement taken from Ernests answer (3) which I cannot explain.
Could someone explain if my deduction is wrong, and why is that?
And if I am not wrong what is the correct answer to the question "Are local variables in static methods also static" ?
EDIT: I am NOT confused by what a local variable OR a member variable (field) OR a static is.
I just thought that:
IF "static methods cannot make reference to non static field" AND "fields are variables"
THEN "variables in static methods are also static"
making a variable in a static method both local && static
Thank you.
fieldis just a naming convention used to describemember variables. So a field is a variable type, just like alocal variableis a variable type. Of course they are not the same type.member variableis just a naming convention used to describefields(in some languages other than Java).