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

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

為啥報(bào)錯(cuò)呀

import java.util.ArrayList;

import java.util.List;


public class TestGeneric {


//帶有泛型---Course的List類(lèi)屬性

public List<Course> course;

private ArrayList<Course> courses;

public TestGeneric(){

this.courses = new ArrayList<Course>();

}

public void testAdd() {

Course cr1 = new Course("1","大學(xué)語(yǔ)文");

courses.add(cr1);

//泛型集合中,不能添加泛型規(guī)定的類(lèi)型以外的對(duì)象,否則會(huì)報(bào)錯(cuò)

//courses.add("我是亂入的哈!");

Course cr2 = new Course("2","Java基礎(chǔ)");

courses.add(cr2);

}

//通過(guò)foreach方法訪問(wèn)集合元素

public void testForEach() {

for(Course cr:courses) {

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

}

public static void main(String[] args) {

TestGeneric tg = new TestGeneric();

tg.testAdd();

tg.testForEach();

}


}


Exception in thread "main" java.lang.Error: Unresolved compilation problem:?

Syntax error, insert "}" to complete Block


at com.collection.TestGeneric.testForEach(TestGeneric.java:26)

at com.collection.TestGeneric.main(TestGeneric.java:31)


正在回答

1 回答

public void testForEach() {

for(Course cr:courses) {

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

}

缺了一個(gè)大括號(hào)}

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

舉報(bào)

0/150
提交
取消

為啥報(bào)錯(cuò)呀

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

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

幫助反饋 APP下載

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

公眾號(hào)

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