问题
I want to convert the integer into char.
Example:-
char c;
for(int i=0;i<10;i++){
system.out.println(" char==="+c);
}
I want to print the c as 0,1,2,3,4..... I had tried :-
c=(char)i; --gives error
c=97-i; -----gives a,b,c
回答1:
Use wrapper classes.
c = new Integer(i).toString().charAt(0);
by the way, you can also use this :
c = (char)(i + 48);
回答2:
Character.forDigit()
http://download.oracle.com/javase/6/docs/api/java/lang/Character.html
来源:https://stackoverflow.com/questions/6210901/convert-integer-to-character-int-j2me