Win a copy of Rust Web Development this week in the Other Languages 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

dif. bt. Static var and intance var.

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi All,
This is the 1st time I am takin a ship of Java cup.
Sooo...I have some doubts. Like....
pls.explain 2 me ..wht. is the dif. between Static variable and Intance Variable?
What u mean by Intance variable??
pls...help me abt. this concept.
Ratul Banerjee.
*************T H A N K S IN A D V A N C E ****************
Round 8.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Static variables are variables which can be accessed without instantiation.
Instance variables are variables which can be accessed only after instantiation.
Static variables are declared with the static modifier.
eg: public static mystat
Static variables are also called class variables as the static variables share the same memory location for all instances of the class.
Start reading a java book.
Kalidas.
 
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Rat Ban,
Hey!!
I suggest you see some tutorials on java instead of posting so minor queries. But one thing, don't consider this as a discouraging statement, anyone is allowed to post any message here as far as java is concerned. But it will be better if you have a look on tutorials. One is available on java.sun.com
another is available with javaranch.com
another is available in a form of a book www.bruceeckel.com
also try www.jguru.com
or maybe maha anna's site.
Finally, another good source is marcus green's site.
I am REPEATING this again to YOU as well as to the MODERATORS, I am NOT making any (NEGATIVE/HURTING/ABUSIVE/DISCOURAGING) statement here, just wish to help you in getting a better feel of basics of java.
Bye,
Tualha Khan
Answers to your queries:
Static variables are those which are part of the class (in question) in whole. They belong to the whole class. Any method can access them. Any updation done to such a variable is affecting the whole class.
Instance variables are those which are a part of the instances of the class (in question). They do not belong to the class as a whole. They are tide to an instance of the class. Any change done to an instance variable is effective to that instance only.
Hope that Helps!!
BYe,
Tualha Khan
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic