본문 바로가기

Java

data type 종류&크기

Java의 data type 종류 & 크기

Java has eight primitive types of data: byte, short, int, long, char, float, double, and boolean.
These can be put in four groups:

정수

Integers includes byte, short, int, and long

실수

Floating-point numbers includes float and double

문자

Characters includes char, like letters and numbers.

논리

Boolean includes boolean representing true/false values.
Type          Explanation

int           A 32-bit (4-byte) integer value

short         A 16-bit (2-byte) integer value

long          A 64-bit (8-byte) integer value

byte          An 8-bit (1-byte) integer value

float         A 32-bit (4-byte) floating-point value

double        A 64-bit (8-byte) floating-point value

char          A 16-bit (2-byte) character using the Unicode encoding scheme
boolean       An 8-bit (1-byte) A true or false value

기본형

정수형 상수의 기본형은 int 고, 실수형 상수의 기본형은 double 이다. 

따라서 long과 float에는 각각 L과 F를 뒤에 붙여주어야 한다.