-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTut4.java
More file actions
36 lines (31 loc) · 750 Bytes
/
Tut4.java
File metadata and controls
36 lines (31 loc) · 750 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package tutorial;
//Operators
public class Tut4 {
public static void main(String[] args) {
// Conditional Operators
int a = 1;
System.out.println(a > 1 ? "yes" : "No");
a = 2;
System.out.println(a > 1 ? "yes" : "No");
// increment and decrement operator
System.out.println("Value of a is " + a);
System.out.println("Incrementing " + a++);
System.out.println("Incremented to " + a);
System.out.println(++a);
System.out.println("Value of a is " + a + "\nDecrementing " + a-- +
"\nDecremented to :" + a + "\nDecrementing Forward " + --a);
}
}
/*
* Output:
* No
* yes
* Value of a is 2
* Incrementing 2
* Incremented to 3
* 4
* Value of a is 4
* Decrementing 4
* Decremented to :3
* Decrementing Forward 2
*/