-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEqualsExample.java
More file actions
31 lines (25 loc) · 948 Bytes
/
EqualsExample.java
File metadata and controls
31 lines (25 loc) · 948 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
package ch05.sec05;
public class EqualsExample {
public static void main(String[] args) {
String strVal1 = "이름";
String strVal2 = "이름";
if (strVal1 == strVal2) {
System.out.println("strVal1과 strVal2는 참조가 같음 ");
} else {
System.out.println("strVal1과 strVal2는 참조가 다름 ");
}
if (strVal1.equals(strVal2)) {
System.out.println("strVal1과 strVal2는 문자열이 같음 ");
}
String strVal3 = new String("이름");
String strVal4 = new String("이름");
if (strVal3 == strVal4) {
System.out.println("strVal3과 strVal4는 참조가 같음 ");
} else {
System.out.println("strVal3과 strVal4는 참조가 다름 ");
}
if (strVal3.equals(strVal4)) {
System.out.println("strVal1과 strVal2는 문자열이 같음 ");
}
}
}