我想打印出一個字符串的ascii值,打印下一個字符,並打印前面的字符。因此,如果用戶輸入b c d
我希望我的程序打印出98 99 100
,也c d e
和最後a b c
。現在是凌晨3點半,爲了讓這些工作正常進行,我的腦子有點油炸了。以下是我有:Java Ascii值
BufferedReader input = new BufferedReader (new InputStreamReader(System.in));
String inputValues3;
// User enters 3 character values here
System.out.println("Enter 3 character values");
inputValues3= input.readLine();
String[] charValues = inputValues3.split("\\s+");
System.out.println(inputValues3); // prints out user character values
System.out.println(); // needs to print out ascii values
System.out.println(); // needs to print out following value
System.out.println(); // needs to print out preceding value
我已經嘗試了幾種不同的方式試圖使人物爲整數值,但是這取決於我如何努力,使其工作已經得到了幾個不同的錯誤。
要打印出Ascii值,只需將'char'轉換爲'int'並打印出 – 2015-01-21 10:40:11
,然後將字符串轉換爲char,然後將char轉換爲int? – 2015-01-21 10:42:11
*「現在是凌晨3點半,我的大腦因試圖讓它們工作而有點油炸。」* - 好吧,上牀睡覺。凌晨3:30,你無法學習編程。 – 2015-01-21 10:43:19