© Kishori Sharan 2017

Kishori Sharan, Beginning Java 9 Fundamentals, https://doi.org/10.1007/978-1-4842-2902-6_7

7. Classes

Kishori Sharan

(1)Montgomery, Alabama, USA

In this chapter, you will learn:

  • What classes are in Java

  • How to declare classes in Java

  • How to declare class members such as fields

  • How to create objects of a class

  • How to declare import statements in a compilation unit

What Is a Class?

Classes are the basic units of programming in the object-oriented paradigm. In Chapter 3, you looked at some elementary aspects of a class in Java, for example, using the class keyword to declare a class, declaring the main() method to run a class, etc. This chapter explains how to declare and use a class in detail.

Let’s start with a simple example of ...

Get Beginning Java 9 Fundamentals: Arrays, Objects, Modules, JShell, and Regular Expressions 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.