• 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
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

object and instance

 
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Can someone tell me what are the differences between instance and object?
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An instance of a class is an object.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Instance" is a more general concept.
As written above, an instance of a class is an object.
An instance of an association is a link (that is, between classes you have associations, between objects you have links).
An instance of a DTD or XML-Schema is an XML-file.
Does that help?
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Thomas and Ilja,
Your answes are useful. I am still not very clear about the instance and object of EJB. It seems they have some diiferent meaning.
For Entity Bean, the application server creates instance, but it is assigned to an remote object only after the create method in the home interface is called.
Does someone have some ideas about the instance in this case?
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Mike Yu:
For Entity Bean, the application server creates instance, but it is assigned to an remote object only after the create method in the home interface is called.


The instance they are speaking of is the object that is instanciated by the application server - the actual entity bean. The remote object is an instance of the remote interface.
Does that make things clearer for you?
 
Mike Yu
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is much better! Thank you, Ilja.
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Their meanings are very close so if you are having trouble differentiating them, its ok.
An object is created from a class. Many objects may be created from the same class. Each of these objects will be referred to as "instances" of that class.
So an object is always an instance, and an instance is always an object.
ClassA refA = new ClassA();
ClassA refA2 = new ClassA();
ClassB refB = new ClassB();
ClassB refB2 = new ClassB();
refA,refA2,refB,refB2 refer to objects;
refA,refA2 refer to instances of ClassA;
refB,refB2 refer to instances of ClassB;
 
Catch Ernie! Catch the egg! And catch this tiny ad too:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic