將 ASCII 程式碼轉換成字串的 Java 程式
要將 ASCII 轉換成字串,請使用 toString() 方法。使用此方法會返回關聯的字元。
假設我們有以下 int 值,可用作我們的 ASCII 碼。
int asciiVal = 89;
現在,使用 toString() 方法。
String str = new Character((char) asciiVal).toString();
示例
public class Demo {
public static void main(String []args) {
int asciiVal = 87;
String str = new Character((char) asciiVal).toString();
System.out.println(str);
}
}輸出
W
廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP