4-2 Prefix

posted Feb 6, 2014, 2:36 AM by Dlovan ismail   [ updated Feb 6, 2014, 2:36 AM by Karwan Jacksi ]
//This program demonstrates the ++ and -- operators in prefix mode.

package prefix;

public class Prefix
{
    public static void main(String[] args)
    {
            int number = 4; // number starts out with 4

            // Display the value in number.
            System.out.println("number is " + number);
            System.out.println("I will increment number.");

            // Increment number.
            ++number;

            // Display the value in number again.
            System.out.println("Now, number is " + number);
            System.out.println("I will decrement number.");

            // Decrement number.
            --number;

            // Display the value in number once again.
            System.out.println("Now, number is " + number);
    }   
}

ċ
Prefix.java
(1k)
Karwan Jacksi,
Feb 6, 2014, 2:36 AM
Comments