• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

static method vs instance method

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What is difference between static method and instance method.
which one one is better in terms of memory and performance.
 
Marshal
Posts: 80665
478
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static methods have nothing to do with performance or memory management. They affect different things. A static member:
  • Is typed by the compiler
  • Is not polymorphic
  • Cannot be overridden, only hidden
  • Belongs to the class, not the object
  • There is only one copy of it per class
  • Every object of that class has access to the same static member
  • Static methods cannot access instance methods or instance fields.
  •  
    Ranch Hand
    Posts: 202
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    all depend on of the your objective, but static method, this pertence the class and instance method pertence the an object, this do not have relation with a class.
    in terms of perfomance nothing change.
    reply
      Bookmark Topic Watch Topic
    • New Topic