This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'll have a try; a class is like a template for an object, an object is an instance of a class.
As a real world example;
a Porsche 911 C2 S Cabriolet is a type (or class of car), there are many Porsches of this model on the road and you could think of each of them as an instance of that car and as an object.
Java is just like this a class is the description of a of the attributes and functionality of an object, it's like a blue print. But you can't use a blue print accept to create an object, you can however use the object much as you can use a car. Creating an Object from a class is refered to as creating an instance of the class), in thory you can make as many objects from one class as you like and use them all independently but they all function as described in the blue print (class).
It's a bit more complex in JAVA because of the static keyword, a static member or method of a class can be used direct from the blue print without making an object and a static member of a class shares it's value across all instances of that class.
I have a class called "Man"
It has two attributes defined; Height, Number of eyes (this is defined as static in the class)
I create two instances of the Man class call then Colin & Dave
I can set the height of Colin to 172cm and set the hieght of Dave to 100cm. They are seperate objects so they each have a seperate Height attribute because it's not static. "Man" does not have a value for Hieght because it's a blue print not a specific object.
Because "Number of Eyes" is defined as static I "Man" does have a value for that which it shares with Colin & Dave because they are instances of that class. They do not have their own copy of this attribute there is only 1 copy for all objects of the class as it's static. So if I change a static attribute it would effect all objects of that class in that have been created and all future objects of that class created.
Statics useful for values that will apply equally to all objects created from a class because it means you can change the attribute once and it will apply to all current and future objects of that type, it's also useful for constants because it saves storing a new copy of the attribute in memory every time you make a new object from the class. It's also useful for methods of a class you want to be able to use without making an object first.