proper way to use list to array?

Posted by cometta on Stack Overflow See other posts from Stack Overflow or by cometta
Published on 2011-01-07T03:48:04Z Indexed on 2011/01/07 3:53 UTC
Read the original article Hit count: 141

Filed under:
public class TestClass{


private String divisions[] ={};


public void doAction(){

 Collection testArray = new ArrayList();
 // put testArray will data

  divisions = (String [] )  testArray.toArray(division);    //should i use this
 divisions = (String [] )  testArray.toArray(new String [] {});   //should i use this?

}

}

if i use case 1, and i call doaction multiple time, the division, something will show wrong records if i use case2, divisions will always show the correct records. is my assumption should use case 2?

© Stack Overflow or respective owner

Related posts about java