Hi there,
In my little code snipet below I am trying to convert an arraylist to an array of type contact. Obviously it's expecting an arraylist of type contact to convert it to an array of type contact. But it's picking up the arraylist as type object for some reason.
public void readInfo(){
try{
inputStream = new BufferedReader(new FileReader("conList.txt"));
}
catch(FileNotFoundException e){}
try{
while ((conInfo = inputStream.readLine()) != null) {
infoArray = conInfo.split("\\s+");
//Create new Contact Object
Contact newCon = new Contact(infoArray[0],infoArray[1],infoArray[2],
infoArray[3],infoArray[4],infoArray[5]);
//Add new Contact to ArrayList
contactObj.add(newCon);
MainList.add(infoArray[0]+" "+infoArray[1]);
}
//Convert ArrayList to Array
Contact ia[];
ia = contactObj.toArray();// Error: incompatible types,
// required: Contactkeeper.contact
// found: java.lang.Object[]
}
catch(IOException v){}
}
In my code you can see the comment on where the error is thrown and what error is thrown. Thank you so much for your help!