8 Replies Latest reply: May 22, 2013 10:19 AM by dadams07 RSS

    adding  different  data types to collection & how to retrive ?

      Hi all,

      public static void main(String[] args) {
                ArrayList ar = new ArrayList();
                Iterator it = ar.iterator();
                     String s =(String)it.next();
                     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(VectorDemo.java:18)