์๋ฐ๋ ๊ธฐ๋ณธํ์ (byte, short, int, long, float, double, boolean) ๊ฐ์ด ๋์ผํ์ง ๋น๊ตํ ๋๋ ==๋ฅผ ์ฌ์ฉํ๊ณ
String ํ์ ๊ฐ์ด ๋์ผํ์ง ๋น๊ตํ ๋์๋ equals()๋ฅผ ์ฌ์ฉํ๋ค.
//๊ธฐ๋ณธํ์
int a = 4;
int b = 4;
if(a==b) {
System.out.println("equals");
}else {
System.out.println("not equals");
}
//String ํ์
String test1 = "๋ฌธ์์ด";
String test2 = "๋ฌธ์์ด";
if(test1.equals(test2)) {
System.out.println("equals");
}else {
System.out.println("not equals");
}
'๐ Today I Learned(๊ฐ๋ฐ์ธ์ดํ์ต) > JAVA' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[JAVA] ๋ฌธ์ ๋ฆฌ์คํธ๋ฅผ ๋ฌธ์์ด๋ก ๋ณํํ๊ธฐ (0) | 2023.10.30 |
---|---|
[JAVA] ๋ฌธ์์ด ์๋ฅด๊ธฐ(substring() ํ์ฉ) (0) | 2023.10.27 |
[JAVA] ๋ฌธ์์ด์ ํ๋์ฉ ๋๋๊ธฐ(toCharArray(), charAt() ํ์ฉ) (0) | 2023.10.26 |
[JAVA] ๋์๋ฌธ์ ๊ตฌ๋ถ ๋ฐ ๋ณํ (0) | 2023.10.11 |
[JAVA] ๋ฌธ์์ด์ ๊ธฐ๋ณธํ์ ์ผ๋ก ๋ณํ (0) | 2023.10.10 |