Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Need help with Instance Variable and fields

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. I am completely lost when it comes to the difference between instance variable(non-static fields) and class variables(static fields)? I have looked and researched for the past couple of hours and for some reason I can not figure out what instance really even means in this context? I am just completely lost when it comes to this. Can someone I guess dumb it down for me? Thanks.
 
Sheriff
Posts: 15815
264
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you experimented with some small programs? That's one of the best ways to understand.

The references to the static variable common through instances on lines 17, 18, 20, 23, 24 is not good practice but it demonstrates the behavior of static variables. Basically, static or class variables are shared by all instances. Instance variables are specific to each object/instance.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This video will help
https://www.youtube.com/watch?v=T8dNBmK40d0
 
Danger, 10,000 volts, very electic .... tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic