Комментарии:
It will not work. since i is an instance variable which is associated with the object of the class, but here we have not created any object for the class so memory has not gat allocated for i. But main js static, JVM called main by the class name, for the reason mentioned above non-static variable i is not accessible inside a static method.
ОтветитьThis code does not work because we cannot use non static variables in static method and if we want to use non static we have to make use of objects
ОтветитьCannot work because we cannot use non status variable in static method
ОтветитьSuch worst presentation
ОтветитьThank you sir, my doubt is now clear.
Ответитьbecause the class level variable is a non static and hence it need to create an object to store
ОтветитьCan't we access non-static variables without creating an instance in the main method? Please help
ОтветитьIt will not work because we created instance variable and we didn't created object or instance of the class without creating instance of a class it will not work . Instance variable always created when object is created.
if we use here object reference the it will work like d.i++;
no it will not work
Ответитьno you cannot access a non-
static variable from a static method
No
ОтветитьTill today this is best java tutorials. Im sure even after next 10-20 yrs this tutorial is THE BEST ONE.
ОтветитьNo, because compiler first go in main
And there is no reference of i
Keep rocking Navin
Ответитьnon static field we cant access from static method
ОтветитьHow do i change non static class to static . Which use. function?
ОтветитьNo it raise error
Ответитьthis code wont work because i is a non static variable
ОтветитьWhy non-static method can cal another non static method directly..?
ОтветитьNo it will not work as u suggested in previous video that only static variable can be declared with static method
Ответить