Hi, I am new to java.
what is class and Object exactly?
All are saying class is blue print and object is the thing. I am not getting that clearly.
Could you help me
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Hi, I am new to java.
what is class and Object exactly?
All are saying class is blue print and object is the thing. I am not getting that clearly.
Could you help me
Hopefully this analogy will help:
A class is a "design" blue print, just like a CAD (computer aided design) model of a car. This class can be used to build an object which follows the blueprint (called constructing, or instancing). However, it's important to note that the object is not the class, just like the CAD model is in no way a real car.
Inside of each class, you define how the object is built (constructors and such), what kind of data the built object can contain, and how that object can be used. This is similar to the blue print for a car. While the a real CAD model doesn't specify manufacturing techniques, they do specify certain specifications that must be met in the construction process. The CAD model will specify how many seats the car will have, what kind of engine is inside of it, etc. etc. It will also specify how that car can be used (the big round thing in front of you is for steering, the pedal on the right makes you go faster, and the pedal in the middle is unused ).
Now, just as you can use the same basic CAD model to build several types of the same car (say a red 5 liter V8 corvette as opposed to a blue 5.2 liter V8 corvette), objects can take on similar characteristics.
Now, there's a little bit of terminology. Static refers to anything used in the blueprint, but is constant for all objects of that type. Instance the opposite of static. Between every object build from that model it is possible (note: possible does not mean it has to be) that the object data is different. I can't really think of a clear analogy for this, but hopefully this helps.
jyothishey (January 25th, 2010)
thank you so much