JAVA 제어문

JTH·2023년 1월 25일
0

생활코딩

목록 보기
1/4

boolean Datatype

public class BooleanApp {
 
    public static void main(String[] args) {
         
        //String 문자와 숫자.
        System.out.println("One");
        System.out.println(1);
         
        //boolean 에 속해있는 두가지 타입. 
        System.out.println(true);
        System.out.println(false);
         
        String foo = "Hello world";
        // String true = "Hello world"; <-- 변수의 이름으로 true를 사용할수없다.
        //									boolean의 약속된 표현 (reserved word)
         
        System.out.println(foo.contains("world")); // String은 여러가지 메소드를 가지고있는데.. 
        System.out.println(foo.contains("egoing")); //contains는 String foo 의 boolean 참 거짓
    }
}

public class ComparisonOperatorApp {
 
    public static void main(String[] args) {
         
        System.out.println(1 > 1); // false
        System.out.println(1 == 1); // true
        System.out.println(1 < 1);
        System.out.println(1 >= 1);
         //비교 연산자는 두 개의 변수값 간의 관계를비교
         //하여 참이나 거짓을 반환한다...
    }
 
}
 

profile
//

0개의 댓글