Java - 将int更改为ascii [英] Java - Change int to ascii

查看:132
本文介绍了Java - 将int更改为ascii的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java有没有办法将int转换为ascii符号?

Is there a way for java to convert int's to ascii symbols?

推荐答案

你要转换 int s到 char s?:

Do you want to convert ints to chars?:

int yourInt = 33;
char ch = (char) yourInt;
System.out.println(yourInt);
System.out.println(ch);
// Output:
// 33
// !

或者你想转换 int s到字符串 s?

Or do you want to convert ints to Strings?

int yourInt = 33;
String str = String.valueOf(yourInt);

或者你的意思是什么?

这篇关于Java - 将int更改为ascii的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆