Java Basic Activities: Increment and Decrement Operators





=====================
Code: 
=======================


public class Test23_Pereda_increment {

public static void main(String [] args) {

int x= 1, y = 1;

   ++x;
   ++y;
   
   System.out.println("Value of x: " +x);
   System.out.println("Value of x: " + ++x);
   System.out.println("Value of x: " + ++x);
   
   System.out.println("\n\nValue of y: " +y);
   System.out.println("Value of x: " + ++y);
   System.out.println("Value of x: " + ++y);
   
   
    


}

}
==================================
Sample no. 2



=======================
Code: 
======================


public class Test24_Pereda_Challege {

public static void main(String [] args) {

int x= 1, y = 1;

   ++x;
   ++y;
   
   System.out.println("Value of x: " +x);
   System.out.println("Value of x: " + ++x);
   System.out.println("Value of x: " + ++x);
   
   System.out.println("\n\n\nValue of y: " +y);
   System.out.println("Value of x: " + ++y);
   System.out.println("Value of x: " + ++y);
   
   System.out.println("\n\n\nValue of x: " + --x);
   System.out.println("Value of y: " + --y);
   
   
   
   
}



}

===========================================




Walang komento:

Mag-post ng isang Komento