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

FieldExplanation
Source/Folder NameProvide the correct source name
PackageProvide the appropriate package name
NameProvide the class name with first letter as capital letter
Method StubsIf you want to create the main method by default then just check the respective check box
CommentsIf 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