자바에서 자주 쓰이는 형변환 시리즈를 모아보았다. 매번 까먹는 관계로 적어놔야 한다는;;;
출처는 이곳 입니다.
int to String
String str = Integer.toString(i);
String str = "" + i;String to int
int i = Integer.parseInt(str);
int i = Integer.valueOf(str).intValue();double to String
String str = Double.toString(d);long to String
String str = Long.toString(l);float to String
String str = Float.toString(f);String to double
double d = Double.valueOf(str).doubleValue();String to long
long l = Long.valueOf(str).longValue();
long l = Long.parseLong(str);String to float
float f = Float.valueOf(str).floatValue();decimal to binary
String binstr = Integer.toBinaryString(i);decimal to hexadecimal
String hexstr = Integer.toString(i, 16);
String hexstr = Integer.toHexString(i);
Integer.toHexString( 0x10000 | i).substring(1).toUpperCase());hexadecimal(String) to int
int i = Integer.valueOf("B8DA3", 16).intValue();
int i = Integer.parseInt("B8DA3", 16);ASCII Code to String
String char = new Character((char)i).toString();Integer to ASCII Code
int i = (int) c;Integer to boolean
boolean b = (i != 0);boolean to Integer
int i = (b)? 1 : 0;
트랙백을 보내세요
트랙백 주소 :: http://theeye.pe.kr/trackback/184
-
.setText
Tracked from 천재최은지의블로그♡ 2010/08/16 19:39public int persons_num TextView string_persons; ..... string_persons = (TextView)findViewById(R.id.gametogethermode_text_persons); .... 이렇게 하고 string_persons에 들어있는 수를 나태나고 싶어서 string_persons.setText(persons_num); 이렇게 썼었다. 자꾸 자꾸 뭐가 문제인지 이줄이 오류가 나길래 왜왜왜그럴..



댓글을 달아 주세요
저도 자바나 자바스크립트 쓸 때 매번 헷갈렸는데 이렇게 정리해두니 보기 좋네요. ㅎㅎ
퍼갈께요 ^^
퍼갈게요
우와~오빠 감사해용 잘볼게요~~ㅋㅋ