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 |
i need example for java abstraction. where we use abstraction and why we need abstraction.
What are the advantages of packages in java?
What does java edition mean?
what is collatration?
What are identifiers in java?
What was java originally called?
solve this is my problem byte a=40,byte b=50 both add value is 90 this is with in range of byte... byte range is -128to 127.... why this pgm gives error like type mismatch.... package javapgms; public class byte1 { public static void main(String args[]) { byte a=40,b=50; byte c=a+b; System.out.println(c); } } note : dont use int k... a,b,c are in byte range... mind it..
what is a static block?
Can we overload final method in java?
How do I convert a numeric ip address like 192.18.97.39 into a hostname like java.sun.com?
Why generics are used in java?
What class is used to implement a Throwable array?