• 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:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

Explain instance in java

 
Ranch Hand
Posts: 293
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends, can you explain instance in java. In general instance means "occurence of something" . In java what is instance.
 
Sheriff
Posts: 9697
43
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
lowercase baba
Posts: 13081
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 76830
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

 
Campbell Ritchie
Marshal
Posts: 76830
366
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Better to say "chair" is abstract, and "a red chair" is concrete. "Revolving chair" would be a subtype of "chair".
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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!
 
This tiny ad is guaranteed to be gluten free.
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic