Skip to content

Commit ef387be

Browse files
Operator
Duration 2 days 9/9/23 - 11/9/23
1 parent 524e656 commit ef387be

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

Operator/Precedence.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
public class Precedence {
2+
public static void main(String[] args) {
3+
/* Operators Precedence */
4+
int a = ~8;
5+
System.out.println(a);
6+
7+
char ch ='D';
8+
int result = (Character.isLowerCase(ch)) ? 1 : (Character.isUpperCase(ch)) ? 0: -1;
9+
System.out.println(result);
10+
}
11+
}

Operator/Unary.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
public class Unary {
2+
public static void main(String[] args) {
3+
4+
int a = 10;
5+
6+
// In unary Operator = 1. Pre-Increment or Decrement, 2. Post-Increment or Decrement
7+
8+
// Pre Increment ++a
9+
int b = ++a; // b = a = a + 1 -> a=11;
10+
11+
// Pre Decrement --a
12+
int c = --a; // a=10;
13+
14+
// Post Increment a++
15+
int d = a++; // a=11 'd' use the first value of 'a' means 10 after processing it a = a+1
16+
17+
// Post Decrement a--
18+
int e = a--; // a=10 e=a=11
19+
}
20+
}

0 commit comments

Comments
 (0)