ArrayStoreException()
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Mehrdad_Shabestari
Posted On:   Monday, April 15, 2002 01:46 PM

Could someone point out my goof up? I get an ArrayStoreException() on the bolded line. How do I convert ArrayList to array then? Thanks. Vector namesV = new Vector(); ArrayList nameList = new ArrayList(); String[] name1 = {"Mike", "12-15-1968", "125985789"}; String[] name2 = {"Bill", "10-10-1955", "987852456"}; nameList.add(name1); nameList.add(name2); namesV.add(nameList); Enumeration iter = namesV.elements(); while(iter.hasMoreElements()) { ArrayList nameL = (ArrayList)iter.nextElement(); String[] nameArray = (String[])na   More>>


Could someone point out my goof up? I get an ArrayStoreException() on the bolded line. How do I convert ArrayList to array then?

Thanks.

			
Vector namesV = new Vector();

ArrayList nameList = new ArrayList();

String[] name1 = {"Mike", "12-15-1968", "125985789"};

String[] name2 = {"Bill", "10-10-1955", "987852456"};


nameList.add(name1);

nameList.add(name2);

namesV.add(nameList);


Enumeration iter = namesV.elements();

while(iter.hasMoreElements()) {
ArrayList nameL = (ArrayList)iter.nextElement();


String[] nameArray = (String[])nameL.toArray(new String[0]);



for (int i = 0; i < nameL.size(); i++){

System.out.println("Name: " +nameArray[i]);

System.out.println("DOB: " + nameArray[i+1]);


System.out.println("SSN: " + nameArray[i+2]);

}
}
   <<Less

Re: ArrayStoreException()

Posted By:   Mehrdad_Shabestari  
Posted On:   Monday, April 15, 2002 02:25 PM

I needed a second iterator for the ArraList. Got it.
About | Sitemap | Contact