base and generic type

ArrayList<String> list = new ArrayList<String>(); // Valid. Same base type, same generic type
List<String> list1 = new ArrayList<String>(); // Valid. Polymorphic base type but same generic type
ArrayList<Object> list2 = new ArrayList<String>(); // Invalid. Same base type but different generic type.
List<Object> list3 = new ArrayList<String>(); // Invalid. Polymorphic base type different generic type

I was reading as above and i was not clear what is base and what is generic. Are they saying left hand side(LHS) to = is base whereas RHS is generic.

Please advise
LVL 7
gudii9Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
They seem to be calling the class without the <> as the base, and the class with the <> as the generic
dpearsonCommented:
To expand on this a bit:

ArrayList<String> list = new ArrayList<String>(); // Valid. Same base type, same generic type

They mean the base type is "ArrayList" on both sides (so that's the same base type) and the generic type is "String" on both sides (so same generic type).

So then when it's not identical on both sides like this:
List<String> list1 = new ArrayList<String>(); // Valid. Polymorphic base type but same generic type

The base types are "List" and "ArrayList" (which are compatible - an ArrayList ISA List) and same generic type "String" (same on both sides).

Does that make sense?

Doug

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gudii9Author Commented:
i got it.

As they are talking about generics in that whenver ddifferent generic type then invalid even though same/polymorphic base type.
awking00Information Technology SpecialistCommented:
To expand a little further on Doug's comments -
Polymorphic basically means that an object can be more than one thing. For list1, a List can be an ArrayList so a List of strings can be an ArrayList of strings, but a List can also be a LinkedList, a Stack, a Vector, and other list types. For list2 and list3, an Object can be a lot of things besides a String. Even though a String is an object, the properties and methods of the two are entirely different. You can have a list of tools (that have numerous uses), but a list of tools can't be a list of saws (that basically can only cut).
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.