1 / 10

Important of Static Keyword in Java Programming Language

Are you in search of the best Java Trainer in Pune? Then your search ends here! We are experts in granting exceptional Java Training in Pune. To get the holistic Java Programming Training in Pune you can join us. We conduct Java Developer Training by the professionals from MNCs who have years of experience in this field. If you want to create a stunning and bright career that yields you more in the future, then consider getting skillful in Java programming. Call us now and mark your admissions soon.<br><br>About us: "Javabykiran" Provide the best python training in Pune. We have 12 years of experience in teaching in java training in Pune, we provide the best java classes in Pune. Our Python classes in Pune are trending in Pune. <br>Follow us on:<br>Facebook- https://www.facebook.com/javabykiran<br>Twitter- https://www.twitter.com/javabykiran<br>Instagram- https://www.instagram.com/javabykiran<br>Visit- https://www.javabykiran.com<br>For Video Tutorials: http://bit.ly/2mLWCxV

javabykiran
Download Presentation

Important of Static Keyword in Java Programming Language

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Presentation on Static keyword JBK By javabykiran, Pune Javabykiran Website: www.javabykiran.com Contact : 8888558802

  2. Static Keyword in JAVA Website: www.javabykiran.com Contact : 8888558802

  3. About Us www.javabykiran.com Having experience in teaching Java for more than 8 years on part-time basis. Has more than 12 years of work experience in IT industry. Till now many projects have been successfully completed and has given guidance to more than 4000 students. Copyrights © 2019 Java By Kiran All rights reserved. 

  4. JBK Things to Remember: Static is a keyword used for memory management Static means single copy storage for variable or method Static keyword can be applied to variables, methods, inner class and blocks Static members belongs to class rather than instance of class www.javabykiran.com Copyrights © 2019 Java By Kiran All rights reserved. 

  5. JBK Things to Remember: www.javabykiran.com Static in java is a keyword that indicates that the variables or functions are shared between all the instances of a particular class since it belongs to the type, not the object. It is used when the programmer wants to share the same variable or method of a class. Copyrights © 2019 Java By Kiran All rights reserved. 

  6. JBK Static Variable: www.javabykiran.com • The variable preceded by ‘static’ keyword is ‘static variable’ static int a=10; //variable static void m1() { // method } • Static variable is used to refer common property of all objects of class Copyrights © 2019 Java By Kiran All rights reserved. 

  7. JBK How to access static variable? www.javabykiran.com There are two ways to access static variable: Static variable can be accessed by Class name A. a ; [A is class name] Where A is the class name and ‘a’ is a static variable declared in that class Static variable can be accessed by object I have a class name called ‘Sample’. Now, we can create the object of the Sample class Sample h=new Sample (); System.out.println(h.a); //’a’ is static variable inside ‘sample’ class Copyrights © 2019 Java By Kiran All rights reserved. 

  8. JBK • How can I access static variable in two ways? Output Copyrights © 2019 Java By Kiran All rights reserved. 

  9. JBK • In the above program, we printed the value of variable by using object name and by using class name • Static variable gets loaded into the memory at the time of class loading • So, we can access static variable by reference variables as well. • In the above program, if we create only the reference of class like Staticvar s1=null; System.out.println(s1.i); // possible System.out.println(Staticvar.i); //possible The above example compiles and executes successfully because the static variable get loaded into the memory at the time of class loading • Static variable and method doesn't belong to Object/Instance of the class since static variables are shared across all the instances of Object. Copyrights © 2019 Java By Kiran All rights reserved. 

  10. JBK Thank You. JBK Javabykiran 8888558802 javabykiran@gmail.com www.javabykiran.com javabykiran

More Related