+ 2
What is the diferencce between CLASS and Objects on Java??
5 Respuestas
+ 4
If you know javascript think a class in java as a function in javascript. And think object as a var. here you only just have to use the "new" keyword.
Look at the syntax and figure out the difference yourself.
class myclass {
}
object myobject = new myclass();
see both are different.
+ 3
Class are the definition, where you put all the atributes and methods, the mould. Objects are instances of a class. They have all the moethods and atributes from their classes.
Example:
you have the class Person, and the object p1 , wich is a Object , with type Person.
Person p1 = new Person();
+ 2
You can think of classes like a blueprint. For example the blueprint of a house, 4 windows, 2 doors, 4 walls, a roof, etc. You use the blueprint to build houses. The houses would be the objects.
+ 1
I wouldn't say that the class contains the objects but rather the class defines the objects. A Car class might define what a car is or has such as steering wheel, doors, wheels, engine, but the objects are the cars, BMW, Mercedes, Ford, Toyota, etc...
0
the class contains the object. It's correct??