long money = 10000; // 4byte에 저장된 10000이 8byte로 promotion된다. System.out.println(money); int score = 100; double realScore = score; //4byte int가 8byte double로 promotion된다. System.out.println(realScore);
-결과
int score = 256; byte realScore = (byte)score; System.out.println(realScore); double grade = 4.5; int realGrade = (int)grade; System.out.println(realGrade); //소수점은 항상 잘려 나간다.
-결과
String strScore = "100"; String strMoney = "100000000000"; String strGrade = "4.5"; int score = Integer.parseInt(strScore); long money = Lomg.parseLong(strMoney); double grade = Double.parseDouble(strGrade); // 자주 사용하는 코드들이니 반드시 암기
// 100 → "100" , 4.5 → "4.5" int age = 100; String strAge = String.valuOf(age); System.out.println(strAge);