JAVA


  • After the Simple Codes, then go to complex Codes that are very important.

    1.   Print Hello World on console


    public class FirstOne{
         public static void main(String  args[]){
                                System.out.println("Hello World”);                                   
                                                }
                                }

    2. Pre-fix and Post-fix Operators

                              public class IncrementExample{
                                       public static void main(String  args[]){
                                                  int x=10;
                                                  int y;
                                                  y = x++;
                                                  System.out.println(x +" "+y);
                                           
                         y = x++;
                         System.out.println(x +" "+y);                                                                   
                                              }
                            }

    The answer comes as:
     x=11, y=10.
     x = 12, y = 12

    Process 1:                                                  Process 2:
    y=10++;                                                                  y =11++;         
    y = 10;                                                                     y = 12;
    x = 11;                                                                     x = 12;

                                                                                                               










    No comments:

    Post a Comment