This discussion is archived
8 Replies Latest reply: May 22, 2013 8:19 AM by aksarben RSS

adding  different  data types to collection & how to retrive ?

1008567 Newbie
Currently Being Moderated
Hi all,

public static void main(String[] args) {
          ArrayList ar = new ArrayList();
          Iterator it = ar.iterator();
               String s =(String);
               System.out.println("vlaues are :::"+s);
Here I am getting Exception:
Exception in thread "main" vlaues are :::Sting1
java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
     at collections.VectorDemo.main(


  • Correct Answers - 10 points
  • Helpful Answers - 5 points