我们可以将整数转换为字符 [英] can we convert integer into character
本文介绍了我们可以将整数转换为字符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我们可以将字符转换为等同于相同ASCII值的整数,但我们可以做相反的事情,即将给定的ASCII值转换为其等效字符吗?
we can convert character to an integer equivalent to the ASCII value of the same but can we do the reverse thing ie convert a given ASCII value to its character equivalent?
public String alphabets(int[] num)
{
char[] s = new char[num.length];
String str = new String();
for(int i=0; i< num.length; i++)
{
s[i] = 'A' + (char)(num[i]- 1);
str += Character.toString(s[i]);
}
return str;
}
显示可能丢失精度错误...
shows possible lost of precision error ...
推荐答案
转换为/来自:
int i = 65;
char c = (char)i;
char c = 'A';
int i = (int)c;
这篇关于我们可以将整数转换为字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文