第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Java - 遇到空格進(jìn)行 ASCII 轉(zhuǎn)換時 Printf 損壞

Java - 遇到空格進(jìn)行 ASCII 轉(zhuǎn)換時 Printf 損壞

元芳怎么了 2021-12-22 19:26:53
我有一個腳本,它應(yīng)該采用一個由數(shù)字和字母組成的字符串,并將它們分解為ASCII/Hex相應(yīng)列下的值。它可以完美運行,直到我在字符串中的任何位置放置一個空格。它將正常打印所有內(nèi)容直到空格,然后中斷沒有錯誤。Ex. (works):kdillon76Ex. (does NOT work):kdillon 76在我的 For 循環(huán)中,我有一個 If 語句,說明如果字符是數(shù)字,則“執(zhí)行此操作”,然后是一個 Else 語句以涵蓋任何“其他”內(nèi)容。Else 語句不應(yīng)該能夠?qū)⒖崭褶D(zhuǎn)換為“32”ASCII 數(shù)字嗎?非常感謝任何和所有幫助!  import java.util.*; // Load all Utility Classespublic class DKUnit3Ch12 { // Begin Class DKUnit3Ch12    public static void main(String[] args) { // Begin Main        Scanner myScan = new Scanner(System.in); // Initialize the Scanner        String myInput; // Define a new Variable        System.out.print("Please enter a string of any length: "); //Print the text        myInput = myScan.next(); // Define a new Variable with the next user input        System.out.printf("%n%-8s%-16s%-16s%s%n", "Initial", "ASCII(char)", "ASCII(int)", "Hex"); // Print the labels with proper tablature        for(int x = 0; x < myInput.length(); x++) { // Begin For Loop            char myChar = myInput.charAt(x); // Define a new Variable based on position in index            if(Character.isDigit(myChar)) { // Begin If Statement (if the character is a digit)                System.out.printf("%-24s%-16d%02X%n", myChar, (int)myChar, (int)myChar); // Print the items with proper tablature including capitalized Hex            } // End If Statement            else { // Begin Else Statement (if the character is NOT a digit)                System.out.printf("%-8s%-32d%02X%n", myChar, (int)myChar, (int)myChar);  // Print the items with proper tablature including capitalized Hex            } // End Else Statement        } // End For Loop        System.out.print("\nThank you for playing!"); // Print the text        myScan.close(); // Close the Scanner    } // End Main} // End Class DKUnit3Ch12
查看完整描述

2 回答

?
holdtom

TA貢獻(xiàn)1805條經(jīng)驗 獲得超10個贊

文檔

A Scanner breaks its input into tokens using a delimiter pattern, which by default matches whitespace.


查看完整回答
反對 回復(fù) 2021-12-22
?
RISEBY

TA貢獻(xiàn)1856條經(jīng)驗 獲得超5個贊

替換myScan.next()myScan.nextLine()


查看完整回答
反對 回復(fù) 2021-12-22
  • 2 回答
  • 0 關(guān)注
  • 264 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號