0

Is it true that if we create variables inside static method is also become static ?

20th Dec 2016, 6:49 PM
Suprakash Pal
Suprakash Pal - avatar
2 Antworten
+ 1
no. variables what declared inside static methods are local variables. but static methods cant use instance variables, only class and local ones.
20th Dec 2016, 6:51 PM
DFX
DFX - avatar
+ 1
No, what you actually heard was You can only use class static members inside a static method. This was meant to say you can't access non static members of a class inside a static function unless you are explicitly passing an object of the class to that static function. And yeah if you declare any variable inside a static method, they are just local variable and don't become static unless you explicitly use the static keyword in their definition!
20th Dec 2016, 9:10 PM
Caffeinated Gamer YT
Caffeinated Gamer YT - avatar