The Artima Developer Community
Sponsored Link

Java Buzz Forum
What is static class, variable, method and field example in Java

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Javin Paul

Posts: 1090
Nickname: javinpaul
Registered: Jan, 2012

Javin Paul is Java Programmer working on Finance domain.
What is static class, variable, method and field example in Java Posted: Nov 23, 2012 10:53 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Javin Paul.
Original Post: What is static class, variable, method and field example in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
Latest Java Buzz Posts
Latest Java Buzz Posts by Javin Paul
Latest Posts From Java67

Advertisement


What is static in Java
Static in Java is related to class, if a field is static means it belongs to class, similarly static method belongs to classes and you can access both static method and field using class name e.g. if count field is static in Counter class than you can access it as Counter.count, of course subject to restriction applied by access modifier e.g. private fields are only accessible in class on which they are declared, protected fields are accessible to all classes in same package but only accessible in sub class outside package. See private vs protected vs public for complete details on access modifier. Similarly if you have a static method increment() in Counter class which increment counter than you can call it as Counter.increment(). There is no need to create an Object of Counter class to access either static method or static field, this is main difference between static and non static members.
Read more »

Read: What is static class, variable, method and field example in Java

Topic: Using Jasper Reports to create reports in Java Previous Topic   Next Topic Topic: MyBatis Tutorial – CRUD Operations and Mapping Relationships – Part 2

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use