BackEnd/JAVA

1. 자료형(Date Type )

BlancPong 2022. 2. 17. 12:01
728x90
//import static java.lang.System.out;

public class DataType {
	// Class Member Variables
	// 자료형(Data Type)
	// 정수형(Integer)
	// 1. 메모리 관리, 효율성
	// 2. 엄격한 자료형 검사
	public byte b = 1;		// 1Byte, 0~255
	public short s = 10;	// 2Byte, short int
	public int i = 100;		// 4Byte, integer
	public long l = 1000;	// 8Byte, long int
	
	// 실수형(Floating-Point, 부동소수점)
	public float f = 3.14f;	// 4Byte (float을 쓸때는 f를 붙여야 출력이됨)
	// Double Precision Floating-Point2222
	public double d = 3.14; 	// 8Byte
	
	// 문자, 문자열
	public char c = 'c';				// 2Byte character
	public String str = "String"; 	// char[]
	
	// 참, 거짓
	public boolean bool = true;
	
	// Class Member Methods
	
	public void print() {
		System.out.println(b + "(" + Byte.BYTES + "byte)");
		System.out.println(s + "(" + Short.BYTES + "byte)");
		System.out.println(i + "(" + Integer.BYTES + "byte)");
		System.out.println(l + "(" + Long.BYTES + "byte)");
		
		System.out.println(f + "(" + Float.BYTES + "byte)");
		System.out.println(d + "(" + Double.BYTES + "byte)");
		
		System.out.println(c + "(" + Character.BYTES + "byte)");
		System.out.println(str);
		
		System.out.println("boolean: " + bool);
	}
}