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

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

獲取非空白輸入的方法

獲取非空白輸入的方法

慕尼黑8549860 2021-06-11 18:08:44
我已經(jīng)制作了采用非空白輸入的方法,因此我可以驗證我的列表中的輸入。public String getNonBlankInput(String text){    Scanner scan = new Scanner(System.in);    System.out.println(text);    String input = scan.nextLine();    while (input.isEmpty() || input.equals(" ")) {        System.out.println("Input is empty.");        System.out.println(text);        input = scan.nextLine();    }    scan.close();    return input;}我想在我的方法中使用它,它將對象添加到我的 LinkedList。下面是這個方法的代碼:public void addMenu(){    String log = getNonBlankInput("Enter login: ");    String pass = getNonBlankInput("Enter password: ");    String web = getNonBlankInput("Enter website: ");    Entry newEntry = new Entry(web,log,pass);    edao.addEntry(newEntry);}問題是,無論我輸入什么登錄名、密碼或網(wǎng)站,我都會遇到異常:Exception in thread "main" java.util.NoSuchElementException: No line foundat java.util.Scanner.nextLine(Scanner.java:1540)at com.password.PasswordManager.data.InputValidation.getNonBlankInput(InputValidation.java:12)at com.password.PasswordManager.input.MenuImplementation.addMenu(MenuImplementation.java:15)任何人都知道這里出了什么問題?在我創(chuàng)建方法 getNonBlankInput 之前,一切正常。
查看完整描述

3 回答

  • 3 回答
  • 0 關(guān)注
  • 181 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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