Source Code
package MyPackage;
public class IncrementOperator {
public static void main(String[] args) {
// Increment
int x = 10;
x++ ;
System.out.println(x);
// Post Increment
int y = 20;
System.out.println(y++);
System.out.println(y);
// Pre Increment
int z = 30;
System.out.println(++z);
// Fixed Increment
int m = 10;
m += 5 ; // x = x + 5
/*
m -= 5 ; x = x - 5
m *= 5 ; x = x * 5
m /= 5 ; x = x / 5 */
System.out.println(m);
}
}
Output
11
20
21
31
15
0 Comments