Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

class and instance?

 
raymond yadao
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm just want to know if what's the difference of class methods and instance method? When to use class methods or instance methods?
thanks!

raymond
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use instance methods if the result or side-effects depend on the state or contents of the object. Use class methods if the result depends only on its arguments or on other "static" data.
 
raymond yadao
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Frank Carver:
Use instance methods if the result or side-effects depend on the state or contents of the object. Use class methods if the result depends only on its arguments or on other "static" data.

can you elaborate further or give an examples?
raymond
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic