JAVA: 진법과 자료형

class CharToCode {

public static void main(String[] args) {

char ch=’A’; // char ch=65;

int code = (int)ch; // ch to int type

 

System.out.printf(“%c=%d(%#X)%n”, ch, code, code);

 

char hch=’a’;// 97;

System.out.printf(“%c=%d(%#X)%n”, hch, (int)hch, (int)hch);

}

} // find the korean windows

 

clip_image001[4]

 

class OverflowEx {

public static void main(String[] args) {

short sMin = -32768;

short sMax = 32767;

char cMin = 0;

char cMax = 65535;

 

System.out.println(“sMin = ” + sMin);

System.out.println(“sMin-1 = ” + (short)(sMin-1));

System.out.println(“sMax = ” + sMax);

System.out.println(“sMax+1 = ” + (short)(sMax+1));

System.out.println(“cMin = ” + (int)cMin);

System.out.println(“cMin-1 = ” + (int)–cMin);

System.out.println(“cMax = ” + (int)cMax);

System.out.println(“cMax+1 = ” + (int)++cMax);

}

}

 

clip_image002[4]

 

class FloatEx1 {

public static void main(String[] args) {

float f  = 9.12345678901234567890f;

float f2 = 1.2345678901234567890f;

double d = 9.12345678901234567890d;

 

System.out.printf(“   :   123456789012345678901234%n”);

System.out.printf(“f  :   %f%n”, f); // print ‘.’ below 6 space

System.out.printf(“f  : %24.20f%n”, f);

System.out.printf(“f2 : %24.20f%n”, f2);

System.out.printf(“d  : %24.20f%n”, d);

}

}

 

clip_image003[4]

 

class CastingEx4 {

public static void main(String[] args) {

int i = 91234567; // 8 int

float f = (float)i; // int to float

int i2 = (int)f; // float to int

 

double d = (double)i; // int to double

int i3 = (int)d; // double to int

 

float f2 = 1.666f;

int i4 = (int)f2;

 

System.out.printf(“i=%d\n”, i);

System.out.printf(“f=%f i2=%d\n”, f, i2);

System.out.printf(“d=%f i3=%d\n”, d, i3);

System.out.printf(“(int)%f=%d\n”, f2, i4);

}

}

clip_image004[4]

 

자바의 정석: http://www.yes24.com/24/goods/24259565

이것도 살펴보세요!

Vue3: 프로젝트 폴더/파일 구성, ESLint

새로 만든 Vue 프로젝트의 폴더/파일 구성 폴더/파일내용.vscodeVisual Studio용 설정 파일dist배포용 파일 세트를 저장node_modules라이브러리를 저장public웹으로 공개할 …

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다