Home Java Example Java Core First Java Program Example



First Java Program Example
Posted on: December 31, 2012 at 12:00 AM
In this section we will discuss about the first java program example.

First Java Program Example

In this section we will discuss about the first java program example.

To create a Java program we would be required to create a Java class. In this class we will print a string like "IIT Mumbai". To demonstrate about a Java program I am giving a simple example.

Example

Here I am giving a simple example which will demonstrate you about how to write your first program in Java. In this example I have created a simple class named College.java. In side this class created a method named displayDetails() which will print the string "IIT Mumbai" on call. This class also contained a public static main method inside which Instantiate the class and called the method displayDetails().

Source Code

public class College
{
    String str = "IIT Mumbai";

    public void displayDetails()
      {
          System.out.println(str);
      }
    public static void main(String args[])
      {
          College college = new College();
          college.displayDetails();
      }
}

Output

Download Source Code

Related Tags for First Java Program Example:


More Tutorials from this section

Ask Questions?    Discuss: First Java Program Example  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.