IT 언어 실제

[자바/2일차] 기본데이터형 8가지 본문

Java

[자바/2일차] 기본데이터형 8가지

닻별이 2013. 11. 27. 18:00

// 기본 데이터형 8가지

class Day02 {
    public static void main(String[] args) {
        boolean bool = true;                    // true 혹은 false

        byte bte = 127;                            // -128 ~ 127 까지 표현가능
        short srt = -32768;
        short srt2 = 32767;
        int it = -2147483648;                    // -2147483648 ~ 2147483647 까지 표현가능
        int it2 = 2147483647;
        long lo = 9223372036854775807L;  // -9223372036854775808 ~ 9223372036854775807 까지 표현가능

        char cr = 'j';                             // 한글자만 표현가능
        char cr2 = 65;                           // 65번부터 알파벳 표현가능
       
        float ft = 3.5415F;                        // -3.4 ~ 3.4 까지 표현가능
        double db = 3.141592;                  // -1.7 ~ 1.7 까지 표현가능

        System.out.println("boolean의 값 = " + bool +"\n");

        System.out.println("byte 의 값 = " + bte);
        System.out.println("short 의 값 = " + srt);
        System.out.println("short 의 값 = " + srt2);
        System.out.println("int 의 값 = " + it);
        System.out.println("int 의 값 = " + it2);
        System.out.println("long 의 값 = " + lo +"\n");

        System.out.println("char 의 값 = " + cr);
        System.out.println("char 의 값 = " + cr2 +"\n");
       
        System.out.println("float 의 값 = " + ft);
        System.out.println("double 의 값 = " + db +"\n");
    }
}




================================================================

출력결과 :