2015-09-07 11:44:36 -06:00

27 lines
551 B
Java

// operators/AutoInc.java
// ©2015 MindView LLC: see Copyright.txt
// Demonstrates the ++ and -- operators.
import static com.mindviewinc.util.Print.*;
public class AutoInc {
public static void main(String[] args) {
int i = 1;
print("i : " + i);
print("++i : " + ++i); // Pre-increment
print("i++ : " + i++); // Post-increment
print("i : " + i);
print("--i : " + --i); // Pre-decrement
print("i-- : " + i--); // Post-decrement
print("i : " + i);
}
}
/* Output:
i : 1
++i : 2
i++ : 2
i : 3
--i : 2
i-- : 2
i : 1
*/