private 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错误,提示找不到符号。
答案 0 :(得分:1)
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);