Java Classes Introduction.

Hello! Today, we will be diving into Java classes, a fundamental topic in Object-Oriented Programming. Classes describe how objects should look and behave. By the end of this lesson, you will understand what classes are and you will be able to create and use classes in Java. Let's get started!

What is a Class in Java?

In Java, a class is a cornerstone tool. It is a blueprint from which we create objects. For example, a Bicycle class could include attributes such as gear and speed, as well as methods such as applyBrake and changeGear. Just as a caterer uses a recipe to make cookies, we use classes to create objects in programming.

Creating a Class in Java

The creation of a class begins with the class keyword, followed by a unique class name. It's standard in Java for class names to begin with a capital letter. Here's how to define an empty class called MyClass:

To create an object - an instance of the class - we use new along with the class name:

Sign up
Join the 1M+ learners on CodeSignal
Be a part of our community of 1M+ users who develop and demonstrate their skills on CodeSignal