Posts

Showing posts from January, 2019

Difference Between a Class and an Object

One of the things when I began Object-Oriented-Programming that I had difficulty understanding was the difference between a class and an object. So many developers use the words object and class interchangeably but they are different. I'm hoping that this post will help people understand the difference. A class is what defines an object. People often say that an object is an instance of an class and that is true but I want to simplify it for people who are just starting to code in an Object-Oriented-Programming Language. The way that I can explain it in the simplest terms is you must code a class in order to create an object. Let's look at the example below. I have coded a very basic class called Person which has their first name, last name, and age. This is how you create a class public class Person { private String firstName; private String lastName; private int age; public Person(String firstName, String lastName, int age) { this.firstName = f