[Logo]
Forums Register Login
what is diff betwn object and instance
what is diff betwn object and instance

i have seen in many books object and instance are used interchagebly what is subtle diff betwn object and instance
It's safe to say an object is an instance or instantiation of a class. "instance" is used in more ways than this, so object and instance aren't quite equivalent, but they're close enough for most conversations.
Hi,

If you look at this code.

Button b = new Button();

It creates a button object but the variable b is the instance variable of the Button object.

Hope this helps!
that was my first thought too, but i guess Stan is right: what OP means is instance like when you use the new keyword - you instantiate something
 
Originally posted by Terry Rickson:
Button b = new Button();

It creates a button object but the variable b is the instance variable of the Button object.


Surely b is a reference to the created object, and that object is an instance of the Button *class*?
 
Originally posted by Terry Rickson:
H
It creates a button object but the variable b is the instance variable of the Button object.


Sorry, but that's incorrect terminology. An instance variable is a member variable of an object, used in contrast to class or static variable. "b" is a variable that refers to an object; that object is an instance of Button. But based on that one line of code, we can't tell if "b" is an instance variable or a local variable.
the simple explanation is that....we declare a class and hence we need to declare that class into the main program..

The name of the class is object and the variable declared is the instance of the object



if any other answers then please let me know
 
Originally posted by sreedhara satuluri:

The name of the class is object and the variable declared is the instance of the object


I think we've answered this one well enough now. These subsequent answers are just confusing (and generally wrong.)
Wink, wink, nudge, nudge, say no more ... https://richsoil.com/cards



All times above are in ranch (not your local) time.
The current ranch time is
Nov 19, 2017 17:47:40.