O'Reilly logo

The class of Java by Pravin Jain

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

CHAPTER 5

Defining a Class in Java

In Chapter 3 we have seen that a class is a reference data type. Just like we have primitive data types in Java, which are predefined by the Java language, classes are also data types, but these are defined by a programmer. Just like we can use the primitive data in different applications, the classes defined by a programmer can also be reused in a number of applications.

The methods in a class are like the operators for the data type (class). In Exercise 2.1, we defined the class HelloWorld as a place holder for the Java application. A Java application is defined in a method called main(), so let us call those classes that contain the application (method main) as an application class. All classes need not contain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required