Fallowing icon

Tuesday, September 18, 2012

Hello World



     
    This is the first Java lesson. We will try to write code and after we can discuss what are the important points in this code.

*   First you open Notepad and type blue color code given below. 

 Important- Java is a Case Sensitive, Java is identifying capital letters and simple letters are different. Ex: A and a are different. Type this code in Notepad Carefully, Don't change Capital's simple.


class myfirst{

      public static void main(String args[]){

             System.out.println("Hello World");
      }
}




//Out put-Hello World
                   

* Download this Java code, then compile it and run.


Discussion- 
   

First look carefully this code, you can see we have used closing brackets or symbol for each opening bracket or symbol,that means when we put the opening brackets or symbol it must be end up with the closing brackets or symbol. We open two brackets and we close in two brackets. We open one inverted comma and we close it.
That is very important, When we are coding, we want to be careful for that. If we forget to close the brackets or symbols, Definitely compiler will give an error massage.
   
  
*  class myfirst
              "myfirst" is call class name,we must save the file using the class name, file type is ".java" .


*  public static void main(String args[])

    main           -Method name
    void           -Method return type
    static         -Method modifiers
    public         -Method modifiers
   ()              -Method parameters    
   {........... }  -Method body
    String args[]  -String data type array 

               This is a main method in Java code. It's very important for us. Because every Java code must    include this. Normally we give other commands under this method.


*  System.out.println("Hello World");
               This is a print command, When we give word in the brackets with inverted comma. Java give that for output. Now we use Hello World for that,So when we have run this code we can see Hello World.


   





No comments:

:a   :b   :c   :d   :e   :f   :g   :h   :i   :j   :k   :l   :m   :n   :o   :p   :q   :r   :s   :t

Post a Comment