First Program HelloWorld in JAVA using IntelliJ


Step-1 Launch Intellij

double click the following IntelliJ icon to launch the IntelliJ

 

 

 

 

Step-2: Click New Project

 

Step-3: Select JAVA and click Next

Step-4: Click Next

Step-5: Name the Project and click finish The following screen will appear

 

 

Step-6 Right Click src folder in project space

Clcick New –> package and name the package

packages is a namespace that will be required to contain everything in JAVA. Give name to package and click OK. We can arrange all our JAVA files in packages. packages is a namespace that organizes all related classes and interfaces. So basically we can think of packages as one that simulates folders in your systems for example html files in one folder, images in another folder, applications in yet another and so on. For now let us create a package com.Example or something else

Step-7 Right clcik the package name

click new –> JAVA class

Rules for A JAVA class name:

  • cannot start with a number.
  • No space is allowed between multi word
  • Multi words can be connected with underscore
  • first letter of subsequent word can be capital with no space between words.

Now you can see under the package HelloWorld class is created and the blank class template is visible in IDE as:

package HelloWorld;

public class HelloWorld {

}

class definition in java starts with the keyword public followed by class and class name and empty brackets.

Insside the class we can have a public method public static void main(){} and the class looks as :

package HelloWorld;

public class HelloWorld
{
public static void main(String [] args)

{

}

}

as soon as the main method is written, the run button become visible in IntelliJ IDE. Every application will need a main method. There is also a sort cut for writing this main method. That is just type psvm and press entre and the full method template get typed. The complete program is shown below:

 

Review:

Everything is inside the package com.Softomation

class HelloWorld is public and can can be used accessed anywhere inside the package.

A public class must have a public main method, and that is where all useful code of an application reside.

error: Content is protected !!