I want to search an array of Students and see if the name i have is the same as the name in one of the entries of the array. This is my code:
public static Student searchLast(Stud ent st[],String last){
int N=st.length;
Student foundStudent;
st=new Student[N];
int i=0;
while(i<N&&!las t.equals(st[i].l_name)){
i++;
}
if(i==N){
foundStudent=nu ll;
}
else{
foundStudent=st[i];
}
return foundStudent;
}
public static Student searchLast(Stud ent st[],String last){
int N=st.length;
Student foundStudent;
st=new Student[N];
int i=0;
while(i<N&&!las t.equals(st[i].l_name)){
i++;
}
if(i==N){
foundStudent=nu ll;
}
else{
foundStudent=st[i];
}
return foundStudent;
}
Comment