JAVA
JAVA기본_데이터 타입
ChoiSH313
2018. 12. 31. 17:43
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 |
package org.opentutorials.javatutorials.constant;
public class constant {
public static void main(String[] args) {
float a=2.2; // 오류발생
float b=2.2F; // float 사용
double c = 2.2; // 기본적으로 소수점은 double
int d = 2147483648; // int의 범위 초과
long e = 2147483648; // 오류발생
long f = 2147483648L; // long 사용
byte g = 100;
short h = 200;
}
}
|
cs |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 |
package org.opentutorials.javatutorials.datatype;
public class data_type {
public static void main(String[] args) {
// 정수형
byte a; // 1byte
short b; // 2byte
int c; // 4byte
long d; // 8byte
// 실수형
float fl; // 4byte
double dou; // 8byte
// 문자
char ch; // 2byte
}
}
|
cs |