What is static in java? pls explain in detail...

Showing Answers 1 - 2 of 2 Answers

samyu

  • Nov 24th, 2005
 

static is a java keyword.whenever a variable is defined as  static such variable  will be created  only once in a memory for all the instances of the class.all the instances of the class will share the latest value of the static variable.

  Was this answer useful?  Yes

hi friend,
              static is a java keyword and we don't hava need make a instance of static variable.
                that's why we don't have need to make a instance of main method---Let's look an example:--->

 public class A{
    public void main(){// try to do some work there}

   }
public class B{
    public static void main(String[] args){
       A a=new A();
       a.main();
       }

now compile these file seprately and run.
than again combine the code in a single notepad and compile the code with:--->
javac B.java


than execute.
i think after this i dont hava to tell the reson. If you dont hava clear the code than email your problem.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions