Java爱好这请进!!!
来源:百度知道 编辑:UC知道 时间:2024/06/19 16:18:59
package javaapplication3;
import java.util.*;
public class SearchArraryList {
ArrayList studentList=null;
/** Creates a new instance of SearchArraryList */
public SearchArraryList() {
studentList=new ArrayList();
}
public int searchList(int studentID){
int result=-1;//-1 represents not found
int counter=0;
student tempStudent=null;
while(counter<studentlist.size()){
tempStudent=(Student)studentList.get(counter);
if(studentID==tempStudent.getstdentID())
result=counter;
}
}
return result;
}
package javaapplication3;
import java.util.*;
public class SearchArraryList {
ArrayList studentList=null;
/** Creates a new instance of SearchArraryList */
public SearchArraryList() {
studentList=new ArrayList();
}
public int searchList(int studentID){
int result=-1;//-1 represents not found
int counter=0;
student tempStudent=null;
while(counter<studentlist.size()){
tempStudent=(Student)studentList.get(counter);
if(studentID==tempStudent.getstdentID())
result=counter;
}
}
return result;
}
你这不是完整的程序把
package javaapplication3;
import java.util.*;
public class SearchArraryList {
ArrayList studentList=null;
/** Creates a new instance of SearchArraryList */
public SearchArraryList() {
studentList=new ArrayList();
}
public int searchList(int studentID){
int