2011년 6월 8일 수요일

Java - 1000 단위마다 콤마(,) 삽입하는 펑션

public static String insertComma(String arg){
int j = 0;
String rtnValue = new String();

for (int i = arg.length() - 1 ; i >= 0; i--){
j++;

rtnValue = arg.charAt(i) + rtnValue;
if(i > 0){
if(j == 3){
rtnValue = "," + rtnValue;
j = 0;
}
}
}

return rtnValue;
}

댓글 없음:

댓글 쓰기