在我的代码中,我想访问数组第一个元素 CIS 400 并检查它是否等于提供的字符串,但它正在访问整个数组对象。谁能给我线索如何做到这一点..谢谢...
public class Course1 {
public static void main(String[] args){
int check= GetCourseByCourseID("CIS 400");
if (check==0){
System.out.print("Don't match");
}
}
private static int GetCourseByCourseID(String CourseID) {
for ( int i = 0; i < course.CourseArray.length; i++ ){
if ( CourseID.equals(course.CourseArray[i] )){
return 1;
}
else {
System.out.print(course.CourseArray[1]);
return 0;
}
// ToDO
}
return 2;
}
Course1(String string, String string2, int i, String string3, String string4){
CourseID = "CIS 400";
CourseTitle = "";
CreditHours = 0;
Description = "";
PrerequisiteCourseID = "";
};
}
class course {
static Course1[] CourseArray ={
new Course1 ("CIS 400", "OO Analysis & Design", 4, "Important class", "CIS 110"),
new Course1 ("CIS 150A" , "VB.NET Programming", 4, "Good Introduction to programming", "CIS 100") ,
new Course1 ("CIS 150B", "C# Programming with labs", 4, "Follow-up to CIS 100", "CIS 100")
};
}