Sunday

Hello world Program in Java

    Java is a object-oriented programming language whereas c++ is structural and partial
object-oriented programming language . My first program in java. 
           The syntax of Java is 
           

                    public class classname {            
                   public static void main (String args[]) {                  
                             ur statement ;                      
                          }                
                    }

     As Java is case sensitive language you should be carefully in upper case & lower case letters
             simple program in java
                           

                     public class sample {                    
                     public static void main (String args[]) {                            
                         System.out.println("Hello world");                  
                               }                  
                    }
         Save the above code as sample.java                                                   
         To execute :
           1.    javac sample.java   
           2.    javsample



      Output:

            Hello world

    Explanation of the above code:
              1st line : In java everything  should come inside class 
              2nd line: The program execution will start after the "main"
            

0 comments:

Post a Comment