Last Updated: February 25, 2016
·
606
· scottymc87

Class and Objects! The Difference!

A very common thing to get mixed up are Classes and Objects. I'm here to set the record straight.

If you were to go to beginner Java tutorials around the web whether it be YouTube, Udacity or anywhere really, you'll notice a lot of comments that ask: "What is the difference between a Class and and Object! I'm confused!!" I remember while I was learning early on I had this problem as well because it's something that is never given the time to be explained very well. Enough of my babble, let's get this going.

The way to really understand Classes and Objects is to think of real life objects. Let's use cars for this example. There are many different cars that are made today. Honda makes a popular model called the Accord. Is every Accord the same? You could have two of the same Accords, but having a Class to define how to create each Accord would give you the ability to make each one unique.

So let's say Honda was using Java to create their cars. They would first need a template to create each car. This template would be a Class. Simply put, a Class in Java holds all of your blueprints to create your Objects. Honda would write their Class which we'll name "Car", to hold all of the different values and parameters that could be used to make each car. They could create a car with blue paint. One with red. One with a sunroof. All of these cars would be Objects of the Car Class.

The Class will have all of the available ways you could create your Object! Objects are created from Classes.