[스터디할래 02] 자바 데이터 타입, 변수 그리고 배열

이 글은 ‘백기선’ 개발자님과 함께하는 온라인 자바 스터디에 참여하여 준비/학습한 내용을 정리하는 글입니다.📚

정리는 The Java Language Specification, Oracle을 기반으로 하였습니다.

자바 변수의 타입

공식 문서에서는 ‘The Java programming language is a statically typed language’와 ‘The Java programming language is also a strongly typed language’ 라고 표현하였다. statically typed languagestrongly typed language가 어떤 차이가 있는지 이해가 가지 않아서 찾아보았는데, 두 개념의 차이에 대해서는 프로그래머들 사이에서도 불분명한 것으로 보인다(참고 stackoverflow). Norman Ramsey 교수님은 말씀하셨다. “Every time I see a question about “strong” or “weak” typing, I kill a kitten.”

번외 - null 타입

There is also a special null type, the type of the expression null, which has no name.(https://docs.oracle.com/javase/specs/jls/se8/html/jls-4.html#jls-4.1)

프리미티브 타입 종류와 값의 범위 그리고 기본 값

Integral Type

타입 크기 값의 범위 기본 값
byte 8-bit -128 to 127 0
short 16-bit -32768 to 32767 0
int 32-bit -2147483648 to 2147483647 0
long 64-bit -9223372036854775808 to 9223372036854775807 0L
char 16-bit ‘\u0000’ to ‘\uffff’ \u0000(null)

Floating Type

타입 크기 값의 범위 기본 값  
float 32-bit ? 0.0f(positive zero)  
double 64-bit ?   0.0d(positive zero)

IEEE 754

프리미티브 타입과 레퍼런스 타입

레퍼런스타입

리터럴

변수 선언 및 초기화하는 방법

변수의 스코프와 라이프타임

타입 변환, 캐스팅 그리고 타입 프로모션

타입 변환

타입 캐스팅

타입 프로모션

타입 추론, var