The class ArrayList is often used where the interface List could be used instead. How would i go about replacing the ArrayList by List wherever possible?

Recommended Answers

All 3 Replies

Gosh this sounds a lot like a homework question.
I'm going to assume it is one, and I'm going to be pretty vague.

If I fly into San Francisco and I need a vehicle for the week, I go to the car rental stand. I don't ask the person at the desk for a particular model of car, because I don't care what kind of car it is - all I care about is that it has the functionality defined by the word "car" - I can get into it, start it up, drive it around, park it, put my luggage in the back of it, and so forth - and the details on the nameplate aren't interesting to me.
The guy at the desk, however, has to know what he's giving me - if only so he knows what to expect back from me at the end of the week. So, I ask him for a "car" and he gives me a "Ford Extinction", and off I go, happy as the lark in the clear morning air.

Does that help at all? I hope so - if not, read up the relevant Sun tutorials, especially starting here. You'll find it if you read along a little ways in that.

Thankyou for your time, but no i still dont get it. Looks like i have alot of reading ahead of me...!

It's not so bad. That tutorial should get you there without a lot of trouble. The parable of the rental car will make sense when you understand it - if it doesn't make sense yet, keep looking.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.