Cast array from object[] to specified type

 

this is sample code:

ArrayList a = new ArrayList();
  a.add(new ReportDTO("a","b","c","d"));
  a.add(new ReportDTO("ae","b","c","d"));
  a.add(new ReportDTO("a2d","b","c","d"));
  a.add(new ReportDTO("aed","b","c","d"));
  a.add(new ReportDTO("a3d","b","c","d"));
  ReportDTO[] o = (ReportDTO[]) a.toArray(new ReportDTO[0]);
  for (int i = 0; i < o.length; i++) {
   System.out.println(o[i]);
  }

相关帖子:
  • No Related Posts
  • micas Jun 13th 2005 10:08 pm JavaBasic No Comments yet Trackback URI Comments RSS

    Leave a Reply

    You must be logged in to post a comment.