| Author |
Explain instance in java
|
Rajendra Prakash
Ranch Hand
Joined: Sep 10, 2009
Posts: 293
|
|
|
Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance.
|
 |
Ankit Garg
Saloon Keeper
Joined: Aug 03, 2008
Posts: 9189
|
|
|
Please take time to Carefully Choose One Forum when you start a topic. The servlet forum is for servlet questions. I'll move it to the appropriate forum...
|
SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
|
 |
fred rosenberger
lowercase baba
Bartender
Joined: Oct 02, 2003
Posts: 9956
|
|
in java, an instance is an occurrence of the object.
Someone writes a java file to define a class. This is like a blueprint on what the object looks like and what it does.
Just like you can use the same blueprint over and over to build the same house many times, you can do the same thing with a class. you can make many instances, each of which live in their own place independently of each other.
|
Never ascribe to malice that which can be adequately explained by stupidity.
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
Welcome to JavaRanch
Useful answer, but it would have been easier to read with the CODE button. As you are new, I have edited your post.
|
 |
s.palanivel rajan
Ranch Hand
Joined: Sep 22, 2009
Posts: 40
|
|
hi
instance is nothing but the object of the class...
we can create any no of instance per class..
for example...
a blue print of the cycle will be a class and a single cycle will be the instance...
|
With Regards,
S.Palanivel Rajan B.E.
|
 |
Monu Tripathi
Rancher
Joined: Oct 12, 2008
Posts: 1365
|
|
If you think of a class as a data structure or a type definition. You can think of instance as a snap shot that shows you what values each of the constituent elements of that data structure have at a particular time.
If class is an abstraction. An object is concrete implementation.
For e.g: Chair is an abstraction(an idea).It is intangible. A revolving chair is an implementation of the idea. It is tangible.
|
[List of FAQs] | [Android FAQ] | [My Blog] | [Samuh Varta]
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32712
|
|
|
Better to say "chair" is abstract, and "a red chair" is concrete. "Revolving chair" would be a subtype of "chair".
|
 |
Monu Tripathi
Rancher
Joined: Oct 12, 2008
Posts: 1365
|
|
Campbell Ritchie wrote:Better to say "chair" is abstract, and "a red chair" is concrete. "Revolving chair" would be a subtype of "chair".
My mistake.
Yes, color would be an attribute;"Red" is the color that the chair instance has. "Revolution" is a functionality so subtyping would be a better fit to describe it.
Thanks CR!
|
 |
 |
|
|
subject: Explain instance in java
|
|
|