Tutorials for Java ,Core java ,Advance java ,oracle ,HTML, CSS, JavaScript, Java and other programming language tutorial Learn Java tutorial for beginners with examples in eclipse online. Java tutorial point for core java, servlet, jsp, struts, spring, for learning web technologies online. Content includes tutorials and references relating to HTML, CSS, JavaScript, PHP, AngularJS, SQL, Bootstrap, Node.js, and jQuery this is a website like w3school tutorialspoint etc

Search This Blog

About

Header Ads

Saturday, 3 March 2018

Static Variable In Java

0 comments

Static Variable In Java

------->>>    If the value of a variable not varied from object to  object then it is not recommended to declared variable as instance variable as instance variable we have to declared such type of variable at class level by using  static modifier ..

------->>>  in the case of instance variable for every object a separate copy will be created but in the case of static variable a single copy will be created at class level and shared by every object of the class .

-------->>>   Static variable should be declared within the class directly but outside of any block,method or, constructor .

------->>>   Static variable will be created at the time of class loading and destroy at the time of class unloading .Hence scope of static variable is exactly same as scope of .Class File .

-------->>>   Static variable will be stored in method area ..

-------->>>>   We can access Static variables either by object reference or, class name but recommend to use class name 

-------->>>>   within the same class it is not required to   use class name and we can access directly .

------->>>>>   we can access static variables directly from both instance and static areas .

--------->>>For Static variable jvm Will provide default value and not require to initialization explicitly .

---------->>>..static variable also known as class level variable or fields .


No comments:

Post a Comment