亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

這串代碼報錯 不能循環 為啥呢,有什么辦法能是代碼簡單點嗎?

這串代碼報錯 不能循環 為啥呢,有什么辦法能是代碼簡單點嗎?

慕的地1533170 2016-04-06 16:44:11
報錯類型Exception in thread "main" java.util.NoSuchElementException代碼import java.util.Scanner;public class text { public static void main(String[] args) { // TODO Auto-generated method stub? ? Scanner input=new Scanner(System.in);? ? System.out.println("***************歡迎使用鄭鄭租車系統**************");? ? System.out.println("本公司提供小轎車,小客車,貨車的租用");? ? for(int i=1;i<=3;i++){? ? System.out.println("請輸入你要租用的車型:");? ? String name=input.nextLine();? ? if("小轎車".equals(name)){? ? Zuche text=new 小轎車();? ? text.nums();? ? text.message();? ? System.out.println("http://///是否需要租用其它車型?回答是或者否/////");? ? String ansum=input.next();? ? if("是".equals(ansum)){? ? ? ? continue;? ? }else{? ? break;? ? }? ? }if("小客車".equals(name)){? ? Zuche text1=new 小客車();? ? text1.nums();? ? text1.message();? ? System.out.println("http://///是否需要租用其它車型?回答是或者否/////");? ? String ansum=input.next();? ? if("是".equals(ansum)){? ? ? ? continue;? ? }else{? ? break;? ? }? ? }if("貨車".equals(name)){? ? Zuche text=new 貨車();? ? text.nums();? ? text.message();? ? System.out.println("http://///是否需要租用其它車型?回答是或者否/////");? ? String ansum=input.next();? ? if("是".equals(ansum)){? ? ? ? continue;? ? }else{? ? break;? ? }? ? }? ??? ?? }? ? input.close(); ?}}
查看完整描述

3 回答

?
Geek丶

TA貢獻6條經驗 獲得超0個贊

Zuche text=new 小轎車();

這串代碼里并沒有Zuche這個類,如果有也不能在new后面寫小轎車吧

查看完整回答
反對 回復 2016-04-07
?
極客小白

TA貢獻1條經驗 獲得超0個贊

試著將input.close();注釋掉,

或者給Scanner前加private

或者將input.close();放到else中, ?小白一枚,問了下度娘,有所解,不知是否正確,說錯勿怪。

查看完整回答
反對 回復 2016-04-06
  • 3 回答
  • 0 關注
  • 1662 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號