Eclipse Creating Java Class

Till now we have learnt about the following important topics –

In this chapter we will be learning how to create a Java class

Eclipse Creating Java Class

We can create the Java Class using the following 3 different ways –

  1. By clicking on the File menu and choosing New > class
  2. By right clicking anywhere in the Project Explorer and selecting New > class
  3. By clicking on the New button (Eclipse Creating Java Class - icon) in the Tool bar and selecting class

Steps for creating Java class

Right click on the package explorer in the Eclipse Workspace and then select the class option

Eclipse Creating Java Class

After selecting the class icon we need to fill following information that we have listed in the table –

Eclipse New class name window

Field Explanation
Source/Folder Name Provide the correct source name
Package Provide the appropriate package name
Name Provide the class name with first letter as capital letter
Method Stubs If you want to create the main method by default then just check the respective check box
Comments If you want to generate the default comment then select the check box.

After the creation of the class we can see how class is created in the eclipse –

Viewing class in eclipse