• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference static and non static method  RSS feed

 
amit sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want to know the difference between static and non static method except that we can access the static method by class name .How to choose whether method should be declared as static or non static.
Thanks
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this chapter in The Java Tutorial: Understanding Instance and Class Members
 
suji kumar
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you need the different copies of variable for different object it has to be made instance variabe(non-static). If you want to share a common variable between every object of that class type, you have to go for static variable
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!