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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定

代碼出錯(cuò),。。

package com.imooc.collection;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

import java.util.Scanner;


public class SetTest {

? ? ?

public List<Course>coursesToSelect;

public SetTest()

{

coursesToSelect=new ArrayList<Course>();

}

public void testAdd()

? ? {

? ? Course cr1=new Course("1","數(shù)據(jù)結(jié)構(gòu)");

? ? coursesToSelect.add(cr1);

? ? Course temp=(Course)coursesToSelect.get(0);

? ? // System.out.println("添加了課程:"+temp.id+":"+temp.name);

? ? ?

? ? Course cr2=new Course("2","C語(yǔ)言");

? ? coursesToSelect.add(0,cr2);

? ? Course temp2=(Course)coursesToSelect.get(0);

? ?// System.out.println("添加了課程:"+temp2.id+":"+temp2.name);

? ? ?

? ? //coursesToSelect.add(cr1);

? ? //Course temp0=(Course)coursesToSelect.get(2);

? ? //System.out.println("添加了課程:"+temp.id+":"+temp.name);

? ? // Course cr3=new Course("3","test");

? ? //coursesToSelect.add(4,cr3);

? ? ?

? ? ?

? ? Course[] course={new Course("3","離散數(shù)學(xué)"),new Course("4","匯編語(yǔ)言")};

? ? coursesToSelect.addAll(Arrays.asList(course));

? ? Course temp3=(Course)coursesToSelect.get(3);

? ? Course temp4=(Course)coursesToSelect.get(4);

? ? // System.out.println("添加了兩門課程:"+temp3.id+";"+temp3.name+";"+temp4.id+";"+temp4.name);

? ? ?Course[] course2={new Course("5","高等數(shù)學(xué)"),new Course("6","大學(xué)英語(yǔ)")};

? ? ?coursesToSelect.addAll(2,Arrays.asList(course2));

? ? ?Course temp5=(Course)coursesToSelect.get(2);

? ? ?Course temp6=(Course)coursesToSelect.get(3);

? ? // System.out.println("添加了兩門課程:"+temp5.id+";"+temp5.name+";"+temp6.id+";"+temp6.name);

? ? ?

? ? ?

? ? ?

? ? }

public void testForEach()

? ? ?{

? ? System.out.println("有如下課程待選(通過(guò)foreach的方法):");

? ? for(Object obj:coursesToSelect)

? ? {

? ? Course cr=(Course)obj;

? ? System.out.println("課程:"+cr.id+":"+cr.name);

? ? }

? ? ?}

public static void main(String[] args) {

// TODO Auto-generated method stub

? ? ? ? ?SetTest st=new SetTest();

? ? ? ? ?st.testAdd();

? ? ? ? ?st.testForEach();

? ? ? ? ?Student student=new Student("1","小明");

? ? ? ? ?System.out.println("歡迎學(xué)生:"+student.name+"選課");

? ? ? ? ?Scanner console=new Scanner(System.in);

? ? ? ? ?for(int i=0;i<3;i++)

? ? ? ? ?{

? ? ? ? System.out.println("請(qǐng)輸入課程ID");

? ? ? ? String courseId=console.next();

? ? ? ? for(Course cr:st.coursesToSelect)

? ? ? ? {

? ? ? ? if(cr.id.equals(courseId))

? ? ? ? {

? ? ? ? student.courses.add(cr);

? ? ? ? }

? ? ? ? }

? ? ? ? ?

? ? ? ? ?}

? ? ? ?

? ? ? ? st.testForEachForSet(student); ?

}

? public void testForEachForSet(Student student)

? ? {

? ? for(Course cr:student.courses)

? ? ? ? {

? ? ? ? System.out.println("選擇了課程:"+cr.id+":"+cr.name);

? ? ? ? }

? ? }

}

求解??

正在回答

4 回答

public List<Course>coursesToSelect;

中間的空格,沒有填上去?。?!

public List<Course> coursesToSelect;

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

慕仔7135344 提問者

可是改了之后還是顯示出錯(cuò)
2016-10-31 回復(fù) 有任何疑惑可以回復(fù)我~
#2

慕仔7135344 提問者

非常感謝!
2016-11-02 回復(fù) 有任何疑惑可以回復(fù)我~

那你沒有把代碼復(fù)制到eclipse試試!

0 回復(fù) 有任何疑惑可以回復(fù)我~

沒什么問題吧


0 回復(fù) 有任何疑惑可以回復(fù)我~
少個(gè)空格


0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消
Java入門第三季
  • 參與學(xué)習(xí)       409775    人
  • 解答問題       4546    個(gè)

Java中你必須懂得常用技能,不容錯(cuò)過(guò)的精彩,快來(lái)加入吧

進(jìn)入課程

代碼出錯(cuò),。。

我要回答 關(guān)注問題
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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