공책

기본 자료형 실습 본문

웹 개발/Java

기본 자료형 실습

QTHoney 2013. 8. 26. 10:49

public class Ex1 {

public static void main(String[] args) {

boolean b = true;

System.out.println("b의 값 : " + b);

//문자형은 홑따음표 안에 넣어줘야 하며 한글자 이상 넣을 수 없다.

char ch = 'A';

System.out.println("ch의 값 : " + ch);

//유니코드로 A를 의미하는 한글자가 들어 간 것

char ch2 = '\u0041';

System.out.println("ch2의 값 : " + ch2);

//아스키코드로 65+1 = 66 의 값인 B가 출력된다

char ch3 = 65+1;

System.out.println("ch3의 값 : " + ch3);

//정수형

byte b1 = 127;

short s1 = 32000;

int n1 = 550;

System.out.println("b1 : " + b1);

System.out.println("s1 : " + s1);

System.out.println("n1 : " + n1);

//실수형

float f1 = 3.14f;

float f2 = 150;

System.out.println("f1 : " + f1);

System.out.println("f2 : " + f2);

}

}



'웹 개발 > Java' 카테고리의 다른 글

연산자  (0) 2013.08.26
형변환  (0) 2013.08.26
기본 자료 형  (0) 2013.08.26
클래스 메소드(static method)와 인스턴스 메소드  (0) 2013.08.21
메모리 구조  (0) 2013.08.21
Comments