개발새발 블로그

[Java] 리터럴의 타입과 접미사

컴퓨터/Java
package ch02;

public class VarEx2 {

	public static void main(String[] args) {
		boolean power = true;
		byte b = 127; // -128~127
		System.out.println(power);
		
		int oct = 010;	// 8진수, 10진수로 8
		int hex = 0x10; // 16진수, 10진수로 16
		System.out.println(oct);
		System.out.println(hex);		// prinln은 10진수로만 출력할 수 있고, 접두사, 접미사 출력되지 않음
		// 8진수, 16진수 출력하려면 printf를 사용해야 됨
		
		long l = 100_00_000_000L;
		
		float f = 3.14f;
		double d = 3.14;		// 더블 타입에 f를 붙여도 오류 발생하지 않는다.
		
		System.out.println(10.);
		System.out.println(.10);
		System.out.println(10f);
		System.out.println(1e3);
	}
}