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

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

問(wèn)一個(gè)小問(wèn)題,我for循環(huán)那里出現(xiàn)了null pointer我檢查了幾遍都沒(méi)出問(wèn)題

package mxxx;


public class duoduiduo {


public static void main(String[] args) {

// TODO Auto-generated method stub

? ?

? //學(xué)生信息

? ? ? ? ? ? ? ?Student stu1=new Student(1,"張小跳",18);

? ? ? ? ? ? ? ?Student stu2=new Student(2,"倩倩",19);

? ? ? ? ? ? ? ?Student stu3=new Student(3,"小洛",15);

? ? ? ? ? ? ? ?//課程信息

? ? ? ? ? ? ? ?Course ca=new Course(1122,"政治思想",3);

? ? ? ? ? ? ? ?Course cb=new Course(1125,"高等數(shù)學(xué)",4); ?

? ? ? ? ? ? ? ?//stu1和stu3選了課程ca分別的78和87分

? ? ? ? ? ? ? ?ca.setStudentCourse(new StudentCourse[]{new StudentCourse(stu1,ca,78),new StudentCourse(stu3,ca,87)});


? ? ? ? ? ? ? ?//stu2和stu3選了課程cb,分別的84和68分

? ? ? ? ? ? ? ?cb.setStudentCourse(new StudentCourse[]{new StudentCourse(stu2,cb,84),new StudentCourse(stu3,cb,68)});

? ? ? ? ? ? ? ?//stu1選了ca課程得78分

? ? ? ? ? ? ? ?stu1.setStudentCourse(new StudentCourse[]{new StudentCourse(stu1,ca,78)});

? ? ? ? ? ? ? ?//stu2選了cb課程得84分

? ? ? ? ? ? ? ?stu2.setStudentCourse(new StudentCourse[]{new StudentCourse(stu2,cb,84)});

? ? ? ? ? ? ? ?//stu3選了ca和cb課程分別得87和68分;

? ? ? ? ? ? ? ?stu3.setStudentCourse(new StudentCourse[]{new StudentCourse(stu3,ca,87),new StudentCourse(stu3,cb,68)});

? ? ? ? ? ? ? //課程信息

? ? ? ? ? System.out.println(stu3.getstudentInfo()); ? //輸出學(xué)生1得信息

? ? ? ? ? for(int i=0;i<stu3.getStudentCourse().length;i++){

? ? ? ? ?System.out.print(stu3.getStudentCourse()[i].getCourse().getCourseInfo());

? ? ? ? ?System.out.println(",成績(jī)"+stu3.getStudentCourse()[i].getScore());

? ? ? ? ? }

}


}

class Student{

private int stuId;

private String stuName;

private int age;

private StudentCourse studentCourse []; ?//這個(gè)里面包括學(xué)生信息和課程信息,所以學(xué)生和課程不需要互相自定義類型

public Student (int stuId,String stuName,int age){

this.stuId=stuId;

this.stuName=stuName;

this.age=age;

}

public void setStudentCourse(StudentCourse studentCouse[]){

this.studentCourse=studentCourse;

}

public StudentCourse[] getStudentCourse(){

return this.studentCourse;

}

public String getstudentInfo(){

return "學(xué)號(hào):"+stuId+",姓名:"+stuName+",年齡:"+age;

}

}

class Course{

private int cid; //課程編號(hào)

private String cName;

private int credit; ?//學(xué)分

private StudentCourse studentCourse [];

public Course(int cid,String cName,int credit){

this.cid=cid;

this.cName=cName;

this.credit=credit;

}

public void setStudentCourse(StudentCourse studentCouse[]){

this.studentCourse=studentCourse;

}

public StudentCourse[] getStudentCourse(){

return this.studentCourse;

}

public String getCourseInfo(){

return "課程編號(hào):"+cid+",課程名稱:"+cName+",課程學(xué)分:"+credit;

}

}

class StudentCourse{

private Student student;//學(xué)生信息

private Course course; ?//課程信息

private double score; ? //成績(jī)

public StudentCourse(){};

public StudentCourse(Student student,Course course,double score){//這個(gè)為student和course賦值,所以這個(gè)不需要set方法

this.student=student;

this.score=score;

this.course=course;

}

public String getStudentCourseInfo(){

return "學(xué)生信息"+student+",課程信息"+course+",成績(jī):"+score;

}

//下面這個(gè)我認(rèn)為這個(gè)是點(diǎn)睛之筆

public Student getStudent(){

return this.student;

}

public Course getCourse(){

return this.course;

}

? public double getScore(){

?return this.score;

? }

}


正在回答

2 回答

public void setStudentCourse(StudentCourse studentCouse[]){

this.studentCourse=studentCourse;

}

就這段,兄嘚,你的方法中的參數(shù)數(shù)據(jù)studentCourse少了個(gè)r

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

斗膽請(qǐng)問(wèn)大俠 提問(wèn)者

非常感謝!
2018-08-17 回復(fù) 有任何疑惑可以回復(fù)我~

看了半天,沒(méi)看出問(wèn)題

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

舉報(bào)

0/150
提交
取消

問(wèn)一個(gè)小問(wèn)題,我for循環(huán)那里出現(xiàn)了null pointer我檢查了幾遍都沒(méi)出問(wèn)題

我要回答 關(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)