전공 과목 이수2👨💻/JAVA(공)
자바 | Boolean 부울
천숭이
2021. 3. 29. 22:40
package soobin;
public class Boolean {
public static void main(String[] args) {
System.out.println("1번 "+(1==1));
System.out.println("2번 "+ ("one"=="Two"));
String a = "Hello world";
String b = new String ("Hello world");
System.out.println("3번 "+(a==b));
System.out.println(a.getClass().getName() +"\n"+ b.getClass().getName());
}
}
출력 :
a와 b는 모두 같은 string형이지만 부울대수로는 같이 않다고 출력된다.
new연산자를 이용한 string형 문자열과 그냥 문자열은 같지 않은 듯