最近中文字幕高清中文字幕无,亚洲欧美高清一区二区三区,一本色道无码道dvd在线观看 ,一个人看的www免费高清中文字幕

為了賬號安全,請及時綁定郵箱和手機立即綁定

不能對非靜態(tài)字段coursestoselect進行靜態(tài)引用

程序完全按照視頻輸入,運行時出現(xiàn)異常提示不能對非靜態(tài)字段coursestoselect進行靜態(tài)引用,求解決方案????????

正在回答

3 回答

樓主看下我擅自修改的代碼,看看有沒有違背樓主的意思,首先我把你的?Iterator it = ?CourseToSelect.iterator();改成了TestCourse it = ?new TestCourse();然后還有你的一個while循環(huán),我改過后是正常運行了,樓主的循環(huán)不知道有沒有問題,不過,Iterator it = ?CourseToSelect.iterator();改成TestCourse it = ?new TestCourse();沒錯吧,后面的課程我也沒看,我要是理解錯了,莫怪哈

0 回復 有任何疑惑可以回復我~

package com.imooc;


import java.util.ArrayList;

import java.util.Arrays;

import java.util.Iterator;

import java.util.List;


public ?class TestCourse {

public List CourseToSelect;

public TestCourse(){

this.CourseToSelect =new ArrayList();

}

@SuppressWarnings("unchecked")

public void TestAdd(){

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

CourseToSelect.add(c1);

Course temp1 = (Course)CourseToSelect.get(0);

System.out.println("添加的課程是:"+temp1.id+":"+temp1.name);

Course c2 = new Course("2","C語言");

CourseToSelect.add(0,c2);

Course temp2 = (Course)CourseToSelect.get(0);

System.out.println("添加的課程是:"+temp2.id+":"+temp2.name);

Course[] course1 = {new Course("3","離散數(shù)學"),new Course("4","匯編語言")};

CourseToSelect.addAll(Arrays.asList(course1));

Course temp3 = (Course)CourseToSelect.get(2);

Course temp4 = (Course)CourseToSelect.get(3);

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

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

CourseToSelect.addAll(2,Arrays.asList(course2));

Course temp5 = (Course)CourseToSelect.get(2);

Course temp6 = (Course)CourseToSelect.get(3);

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

}


public static void main(String[] args){

TestCourse it = ?new TestCourse();//這里提示錯誤不能對非靜態(tài)字段 CourseToSelect 進行靜態(tài)引用

it.TestAdd();

}

}


0 回復 有任何疑惑可以回復我~

代碼貼出來看看

0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

不能對非靜態(tài)字段coursestoselect進行靜態(tài)引用

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

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

幫助反饋 APP下載

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

公眾號

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