Sample for Prefix vs Postfix Increment Operator //RUN THIS CODE to help you understand the difference between
Fantastic news! We've Found the answer you've been seeking!
Question:
Sample for Prefix vs Postfix Increment Operator
//RUN THIS CODE to help you understand the difference between the prefix and postfix increment operator
public class PrePostDemo
{
public static void main(String[] args)
{
int i = 3;
i++;
System.out.println(i); //prints out 4
++i;
System.out.println(); //prints out 5
System.out.println(++i); //prints out 6 -- increments then prints
System.out.println(i++); //prints out 6 -- prints then increments
System.out.println(i); //prints out 7 because previous line incremented i
}
}
Related Book For
Computer Organization and Design The Hardware Software Interface
ISBN: 978-0124077263
5th edition
Authors: David A. Patterson, John L. Hennessy
Posted Date: