Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

Instance vs Static Variables, Methods, Constructors? Basic understanding

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello everyone.

I have a test coming up very soon and I was wondering if anyone would be kind enough to explain each of the following to me in way that is easy to understand? I found some explanations online but they are a tad bit beyond my what I can comprehend as far as Java goes.

*Instance Variables (Fields)
*Instance Methods
*Static Variables (Fields)
*Static Methods
*Constructors


Thank you very much!
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is a very big question which isn't easy to explain. Luckily the are a lot of good tutorials out there. This is a great example. I would read that and then come back if you still have questions.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To boil it down...
  • "instance" is associated with a specific object (i.e., an "instance" of a class).
  • "static" is associated with a class, regardless of how many -- if any -- instances might be created.
  • Constructors are code that "instantiate" (create) an Object and prepare that object for use.


  • But as Wouter pointed out, the implications are far reaching. Let us know if you have specific questions.
     
    Java Cowboy
    Posts: 16084
    88
    Android Scala IntelliJ IDE Spring Java
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    From the tutorial that Wouter quoted, this part explains the difference between non-static and static members: Understanding Instance and Class Members.

    And Providing Constructors for Your Classes explains constructors.
     
    Would anybody like some fudge? I made it an hour ago. And it goes well with a tiny ad ...
    the value of filler advertising in 2021
    https://coderanch.com/t/730886/filler-advertising
    reply
      Bookmark Topic Watch Topic
    • New Topic