私人void btnTranslateActionPerformed(java.awt.event.ActionEvent evt){
字符串strSecretMessage;
strSecretMessage = this.txtSecretMessage.getText();
for (int i=0; i < (strSecretMessage.length()-1); i++){
lblACSII.setText(i+" "+ strSecretMessage.charCodeAt(i));
}
}
弹出charCodeAt错误,提示找不到符号。
最佳答案
lblACSII.setText(i+" "+ (int)strSecretMessage.charAt(i));
charAt()
获取字符并将其强制转换为int
将提供ascii值String temp = "";
for (int i=0; i < (strSecretMessage.length()-1); i++){
temp += i+" "+ strSecretMessage.charCodeAt(i) + " ";
}
lblACSII.setText(temp);
关于java - ASCII错误消息,找不到符号,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/51848079/