Creating a class is quite easy, but how you do it depends on what you plan to do with the class. For this step, you'll be creating a class that you can actually run from the command line (or the console, as it's called within Eclipse).
q 7.3(a) Right-click on Hello in the Package Explorer and select New Class.
q 7.3(b) Make sure the Source Folder is Hello.
q 7.3(c) Leave Package blank.
q 7.3(d) Leave Enclosing type unchecked.
q 7.3(e) Enter HeIloWorld in the Name field.
q 7.3(f) Make sure public is checked, abstract and final are unchecked.
q 7.3(g) Leave Superclass as java.lang.Object, Interfaces blank.
q 7.3(h) Make sure public static void main(String args) is checked.
q 7.3(i) Leave the other two unchecked.
q 7.3(j) Click Finish.
Following these steps will create a class HeIloWorld in the default package (because you left Package blank) in project Hello. It will be a public class, neither abstract nor final. The class has no superclass (except for the implied superclass Object) and implements no interfaces. Finally, the IDE has been instructed to create a standard "main" method, but no other methods . That being the case, we will see the result as in Figure 7.10.
There are a number of interesting results from this simple operation.
A default package is added, with the icon. The default package is added because you left the package name blank in Step 7.3(c). Had you entered a package name, that package would have been created instead. Had you used an already existing package, the class would simply have been added to that package.
The class HelloWorld was added. More correctly, the Java source code was added. That's what the icon in the Package Explorer indicates. The class is also created; we'll look into this a little further in a moment.
A class is added with some initial comments. These comments are pretty useless at this point, but you can change them.
To change the default documentation for a new class, go into Window/Preferences. In the Preferences dialog, select Java/Templates and then edit the template named typecomment. You can modify quite a number of templates using this dialog.
The class itself is defined as HelloWorld. You'll also notice that the class is shown in the Outline view.
Last but not least, the main() method is created. It, too, has an entry in the Outline view.