JAVA

JAVA기본_비교와 Boolean

ChoiSH313 2018. 12. 31. 17:40
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
package org.opentutorials.javatutorials.bool;
 
public class bool {
 
    public static void main(String[] args) {
        System.out.println(1 == 3); // false
        System.out.println(1 == 1); // true
        
        System.out.println("one" == "two");
        System.out.println("one" == "one");
        
        System.out.println(1 != 3); // true
        System.out.println(1 != 1); // false
        
        System.out.println("one" != "two");
        System.out.println("one" != "one");
        
        String a = "Hello world";
        String b = new String("Hello world");
        System.out.println(a == b);
        System.out.println(a.equals(b)); // 문자열 비교할때는 equals
 
    }
 
}
 
cs