Below, what's the best way to fix
incompatible types error in method getSize() ?
Thanks.
import java.util.*;
import java.lang.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class FacultyList {
/** Creates a new instance of StudentList */
private List facultys = new LinkedList();
private static FacultyList facultyList;
private FacultyList() {
}
public static FacultyList instance() {
if (facultyList == null) {
return (facultyList = new FacultyList());
} else {
return facultyList;
}
}
public boolean addFaculty(Faculty faculty){
facultys.add(faculty);
return true;
}
public Iterator getFacultys(){
return facultys.iterator();
}
public String toString(){
return facultys.toString();
}
public Faculty Search(String facultyID){
for (Iterator iterator = facultys.iterator(); iterator.hasNext(){
Faculty faculty = (Faculty) iterator.next();
if (faculty.getFacultyID().equals(facultyID)){
return faculty;
}
} return null;
}
public Integer getSize(){
return facultys.size();
//return (Integer) facultys.size(); do not work
}
}
incompatible types error in method getSize() ?
Thanks.
import java.util.*;
import java.lang.*;
import java.io.*;
/**
*
* @author Administrator
*/
public class FacultyList {
/** Creates a new instance of StudentList */
private List facultys = new LinkedList();
private static FacultyList facultyList;
private FacultyList() {
}
public static FacultyList instance() {
if (facultyList == null) {
return (facultyList = new FacultyList());
} else {
return facultyList;
}
}
public boolean addFaculty(Faculty faculty){
facultys.add(faculty);
return true;
}
public Iterator getFacultys(){
return facultys.iterator();
}
public String toString(){
return facultys.toString();
}
public Faculty Search(String facultyID){
for (Iterator iterator = facultys.iterator(); iterator.hasNext(){
Faculty faculty = (Faculty) iterator.next();
if (faculty.getFacultyID().equals(facultyID)){
return faculty;
}
} return null;
}
public Integer getSize(){
return facultys.size();
//return (Integer) facultys.size(); do not work
}
}