将整数转换为字符int j2me [英] Convert integer to character int j2me
本文介绍了将整数转换为字符int j2me的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想将整数转换为char.
I want to convert the integer into char.
示例:-
char c;
for(int i=0;i<10;i++){
system.out.println(" char==="+c);
}
我想将c打印为0、1、2、3、4..... 我试过了:-
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
推荐答案
使用包装器类.
c = new Integer(i).toString().charAt(0);
顺便说一句,您也可以使用它:
by the way, you can also use this :
c = (char)(i + 48);
这篇关于将整数转换为字符int j2me的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文