Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个用例,我想获取以字符串格式表示的字符的 ASCII 值。例如:我有字符串变量 charString="'\0'"。所以我想要字符 '\0' 的 ASCII 值,即 0
字符串 charString = "'\0'";
请让我知道如何在 Java 中实现这一点
你的意思是这样吗?
String charString = "'\0'"; int i = charString.charAt(0); // == 0
这适用于所有小于 65536 的字符,而不仅仅是 ASCII 字符。