why we cannot declare static variable inside a static method
Answers were Sorted based on User's Feedback
Answer / ravikiran
Because all the variales inside static method are by
default static
| Is This Answer Correct ? | 15 Yes | 4 No |
Answer / srinu
generally all variables inside static method treated as
static
| Is This Answer Correct ? | 9 Yes | 3 No |
Answer / sachin kanojiya
Static variable initializes at the time of class load
(static variable initialize very first,after that static
method)that means static variable and method already define
but inside the static method can't declare static variable
because it is treat as static local member...
| Is This Answer Correct ? | 5 Yes | 4 No |
Answer / swamireddy
STATIC VARIABLES ARE DECLARED CLASS DIFINITION ONLY
WITHOUT DECLARE THE WITHIN STATIC METHODS.THE STATIC
METHODS ARE ONLY USE THE STATIC VARIABLES.
| Is This Answer Correct ? | 2 Yes | 2 No |
What is difference between char array and string?
What are Inner classes?
What do you mean by formatting?
What is the importance of hashcode() and equals() methods?
what is aberivation of java?
What happens when a main method is declared as private?
22 Answers DELL, Infosys, L&T, Sun Microsystems,
What is the benefit of using enum to declare a constant?
what are depricated methods in threads and explain the lifecycle methods
Explain the importance of throwable class and its methods?
Why are constructors used?
How to sort array in descending order in java?
What do you mean by JVM?