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.
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.
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
SCJP2, BEA WLS 6.0, DB2 UDB 7.1
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