8 Replies Latest reply on May 22, 2013 3:19 PM by dadams07

    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)