+ 3

It is always confusing for me when it comes to class and instances. Can anyone explain to me??

5th Dec 2017, 4:47 PM
PRASHANTH JOSWIN D'SOUZA
PRASHANTH JOSWIN D'SOUZA - avatar
2 Antworten
+ 13
A class is a blueprint which you use to create objects. An object is an instance of a class - it's a concrete 'thing' that you made using a specific class. So, 'object' and 'instance' are the same thing, but the word 'instance' indicates the relationship of an object to its class. This is easy to understand if you look at an example. For example, suppose you have a class House. Your own house is an object and is an instance of class House. Your sister's house is another object (another instance of class House). // Class House describes what a house is class House { // ... } // You can use class House to create objects (instances of class House) House myHouse = new House(); House sistersHouse = new House(); The class House describes the concept of what a house is, and there are specific, concrete houses which are objects and instances of class House.
5th Dec 2017, 5:17 PM
GAWEN STEASY
GAWEN STEASY - avatar
+ 1
Thank you ☺
5th Dec 2017, 6:45 PM
PRASHANTH JOSWIN D'SOUZA
PRASHANTH JOSWIN D'SOUZA - avatar