What Is a Class?
A class typically represents a type of thing in the world of the application. You define a class, and in it write code that represents two things: the properties of that type of thing and how it behaves. You might think of classes as categories. For instance, Person is a category or type of thing in the world. To make a class, you simply open your editor, type the keywords public class, and give it a name. Save that file with a .java extension and compile it using the javac command that comes with the SDK.
We can make a class called Person like this:
public class Person { }
If you type the preceding code into a text file called Person.java, it will compile. However, it is obviously useless, because it doesn't hold any data, ...
Get Java Garage now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.