I do not understand this.

I get no compiler complaints with this code:

   Collection<?> c = new ArrayList<Integer>
(10);                           // This code works
    c = new ArrayList<Long>
(10);                                                  // This code
works
    c = new ArrayList<String>
(10);                                                // This code
works

But when i try to add an Integer to the ArrayList I get complaints
form the compiler:

   Collection<?> c = new ArrayList<Integer>
(10);                             // This code works
   c.add
(10);                                                                           
        //
Complains ???????????????
   c = new ArrayList<Long>
(10);                                                    // This code
works
   c = new ArrayList<String>
(10);                                                  // Thiscode
works

When i try this:

Collection <Integer> c = new ArrayList<Integer>(10);
c.add
(10);                                                                           
        //
NO PROBLEM

I thought i really understood this section up until this...
Can anyone tell me why the code will not work?

Thanks, Gary






--~--~---------~--~----~------------~-------~--~----~
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