Hey guys, i posted this question to another forum but i didnt get a satisfying answer. What is the exact difference between Object and Instance. Different people and websites offer different explanations and im so confused. What does oracle say about this? and what is your theory? Thanks in advance
An object is an instance of a class. How's that for confusion? :-)
To elaborate a bit more: A class is something lifeless - a .class file that has the potential of doing something - what that is is described in the javadocs of that class. But to make it into an object, you need to call "new MySuperClass()" - which will hand you a reference to the object; now you have something that's alive, and on which you can invoke methods.
So, all objects are instances of some class - which makes the original question a bit pointless. The difference you need to understand is between classes and objects.
Imagine a mould for making say candles. You pour the molten wax in it, let it cool and out comes the candle. You do it 100 times and end up with 100 candles.
The mould is the Class. All the candles you made from the mould are the objects or instances of that class.
There are no differences between an object and an instance. They are the same thing. In other words, in object-oriented terminology, the words "object" and "instance" have the same meaning and authors can use them interchangeably.
Ulf Dittmer wrote:What I was trying to say was that there is no difference:
object = instance of a class
you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.
I'm requesting everyone to give answer of my question please. for your efforts in advance.
Jimmy Clark wrote:There are no differences between an object and an instance. They are the same thing. In other words, in object-oriented terminology, the words "object" and "instance" have the same meaning and authors can use them interchangeably.
you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.
I'm requesting everyone to give answer of my question please. for your efforts in advance.
marc weber wrote:Every object is an instance of a class. And every instance of a class is an object. You can basically interchange these.
you mean authors call it sometime instance and sometime object without any reason then what is meaning of having two name of same thing.I've doubt that there should be any reason .why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.
I'm requesting everyone to give answer of my question please. for your efforts in advance.
Ulf Dittmer wrote:What I was trying to say was that there is no difference:
object = instance of a class
I'm requesting everyone to give answer of my question please. for your efforts in advance.
I dont know what more answers you are expecting.
dear sanaulla I m looking here for solid answer and you know solid means that what is need of having two name object and instance and if there is no reason then why don't we make a great history in java by naming another name of class ? when object has two name then why it's dady has one name ? we should do something about it.
Piyush Joshi wrote:Hi Nitesh, Firstly Please don't post the same question again and again.
Nitesh Nandwana wrote:what is meaning of having two name of same thing.
Why can't someone express something in more than one way, using more than one names?
Nitesh Nandwana wrote:why don't we've two name of class so it's depend on my mood so some time i call it class and sometime anything.
You can make up a name for class and use it depending on your mood. But will the idea or notion of a class change?
The thing that I want to say is that please dont be bothered about names, get the idea or concept.
Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.
Nitesh Nandwana wrote:
Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.
You need not post the same query multiple times with a different quote.
I dont know why you are so much concerned with the terminology. You just relate that both mean the same and you are good to go. There are lot of other things in Java which you have to learn and which are much more important than just- Object or instance.
I can suggest another name for Class- Template.
Nitesh Nandwana wrote:
Dear joshi ji, leave idea and concept beside first thing there shouldn't be any terminology confusion for beginner .if it is then it should be clear never mind even it is small thing,and you can post any question any no of times.
You need not post the same query multiple times with a different quote.
I dont know why you are so much concerned with the terminology. You just relate that both mean the same and you are good to go. There are lot of other things in Java which you have to learn and which are much more important than just- Object or instance.
I can suggest another name for Class- Template.
jake dickens wrote:Think a object is like a remote for the tv you need that object to control but the instance is a copy of the object does that help?
It's really simple: an object is an instance of some class.
A house is built according to a plan, the blueprint. The house is an object, and the house is also an instance of the blueprint.
Saying things like "the instance is a copy of the object" is confusing, I don't know exactly what you mean by it but I don't think it is correct. The word "object" and "instance" are just two words that refer to the same thing, there's nothing with copying going on.