// to create   2 String objects
     2 MyOwnClass object
          o MyOwnClass class has name (String type) and age (int type)
     3 Integer ojbects


import java.util.*;
class MyOwnClass
{
    String name;
    int age;
    MyOwnClass(String n,int a)
    {
        this.name=n;
        this.age=a;
    }
    public String toString()
    {
        return ("Tha name and age from MyOwnClass"+" "+name+" "+age);
    }

}

public class ArrayList {


    public static void main(String[] args) {
    ArrayList a =new ArrayList();
    a.add("bobby");                         //error
    a.add("tommy");
    a.add(5);
    a.add(6);
    a.add(7);
    a.add(new MyOwnClass("bob",15));
    a.add(new MyOwnClass("raju",16));
    Iterator itr = a.iterator();
    while(itr.hasNext())
    {
 Object element = itr.next();
 System.out.println(element+"\n");
    }

}
}
Error:Uncompilable source code...help plz






--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/javaprogrammingwithpassion?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to