1.6. Java Program Structure
Let's summarize how a Java program is structured :
A Java program always consists of one or more classes.
You typically put the program code for each class in a separate file, and you must give each file the same name as that of the class that is defined within it.
A Java source file name must have the extension .java.
Thus your file containing the class Hat will be called Hat.java and your file containing the class BaseballPlayer must have the file name BaseballPlayer.java.
A typical program consists of several files as illustrated in Figure 1-8.
Figure 1.8. Figure 1-8
This program clearly majors on apparel, with four of the five classes representing clothing. Each source file contains a class definition, and all of the files that go to make up the program are stored in the same directory. The source files for your program contain all the code that you wrote, but this is not everything that is ultimately included in the program. There is also code from the Java standard class library, so let's take a peek at what that can do.
1.6.1. Java's Class Library
A library in Java is a collection of classes—usually providing related facilities—that you can use in your programs. The Java class library provides you with a whole range of goodies, some of which are essential for your programs to work at all, and some of which make writing your Java programs easier. ...
Get Ivor Horton's Beginning Java™ 2, JDK™ 5th Edition 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.