• 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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: 79177
377
  • 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.
     
    Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
    a bit of art, as a gift, that will fit in a stocking
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic