October 2011
Beginner
432 pages
10h 18m
English
Although a Java program is called a class, there are many occasions when a program requires more than one class to get its work done. These programs consist of a main class and any helper classes that are needed.
When you divide a program into multiple classes, there are two ways to define the helper classes. One way is to define each class separately, as in the following example:
public class Wrecker { String author = "Ignoto"; public void infectFile() { VirusCode vic = new VirusCode(1024); }}class VirusCode { int vSize; VirusCode(int size) { vSize = size; }}
Caution
If more than one class is defined in the same source file, only one of the classes can be public. The other classes ...
Read now
Unlock full access