Difference between instance and Object in Java
In Java or other object
oriented programming language, we often use Object and instance word
interchangeably, but sometimes it confuses beginners like hell. I have been
often asked several times, whether object and instance are the same thing or
different? Why we sometimes use object and sometimes instance if they are same
thing etc? This gives me the idea to write a little bit about it. I will mostly
talk about Java conventions perspective. Just like we use word function in C or
C++ for a block of code, which can be called by its same, but in Java, we
refer them as methods. In Java functions are known as methods, similarly, objects
are known as instances in Java. You have a class, which represent a
blueprint of a real world thing e.g. Car, and object represents a real
world car e.g. your car, my car, a red car or a blue car. They are also known
as instances of the car.