-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompareOperatorExample.java
More file actions
38 lines (33 loc) ยท 1.3 KB
/
CompareOperatorExample.java
File metadata and controls
38 lines (33 loc) ยท 1.3 KB
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
37
38
package ch03.sec06;
public class CompareOperatorExample {
public static void main(String[] args) {
int num1 = 10;
int num2 = 10;
boolean result1 = (num1 == num2);
boolean result2 = (num1 != num2);
boolean result3 = (num1 <= num2);
System.out.println("result1 : " + result1); // true
System.out.println("result2 : " + result2); // false
System.out.println("result3 : " + result3); // true
char char1 = 'A';
char char2 = 'B';
boolean result4 = (char1 > char2); // 65 > 66
System.out.println("result4 : " + result4); // false
int num3 = 1;
double num4 = 1.0;
boolean result5 = (num3 == num4);
System.out.println("result5 : " + result5); // true
float num5 = 0.2f;
double num6 = 0.2;
boolean result6 = (num5 == num6);
boolean result7 = (num5 == (float) num6);
System.out.println("result6 : " + result6); // false
System.out.println("result7 : " + result7); // true
String str1 = "์๋ฐ";
String str2 = "Java";
boolean result8 = (str1.equals(str2));
boolean result9 = (!str1.equals((str2)));
System.out.println("result8 : " + result8); // false
System.out.println("result9 : " + result9); // true
}
}