public static void main (String[] args) {
char[] msg;
int code;
int i;
String newMsg;
msg = getMsg(); // Read the message from keyboard
code = getCode();
System.out.println("Code : "+code);
for (i=0; i<msg.length; i++){
System.out.println(msg[i]);
System.out.println(Character.toString((char)msg[i]));
newMsg = ("\\u" + Integer.toHexString(msg[i] + code | 0x10000).substring(1));
System.out.println (String.valueOf(msg[i] + code));
System.out.println (newMsg);
}
public static int getCode(){
int code=0;
System.out.print("Input Code: ");
Scanner input = new Scanner(System.in);
return input.nextInt();
}
public static char[] getMsg(){
String myMessage;
System.out.print("Input Message: ");
Scanner input = new Scanner(System.in);
myMessage = input.nextLine();// Read a line of message
return myMessage.toCharArray();
}
мой вывод следующий:Печать Unicode + цифра, как Unicode
Input Сообщение: а Входной код: 1 Код: 1 \ u0062
Я пытаясь добавить CODE в этом случае 1 к a и print b, но я могу только добавить его в unicode или ascii, но я не могу вернуться к b оттуда.