aspose file tools*
The moose likes Beginning Java and the fly likes Problem Interface/Abstract/Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Problem Interface/Abstract/Collections" Watch "Problem Interface/Abstract/Collections" New topic
Author

Problem Interface/Abstract/Collections

stefan bisang
Greenhorn

Joined: Jun 03, 2010
Posts: 3
Hey there

I'm working on a exercise and got the following problem:

I wrot this Interface:


and I've implemented this interface in Class ListOne:



At this point, everything seems fine and okay

Next Step:
I have to implement the a Class ListTow with an LinkedList instead of an ArrayList and of course I should reuse as much as possible code. I know that I have to refactor it :-), but what is now the approach? Should I create an abstract Class for ListOne and ListTwo or how should i proceed?

Thanks a lot for any hints

Cheers
Stefan

Ps: sorry for my bad english, but I'm not a native english speaker


stefan bisang
Greenhorn

Joined: Jun 03, 2010
Posts: 3
Hey there

I've solved the problem, did the following:

Interface:


and then I've created an abstract class aList:


and Class ListOne:


and Class ListTwo



Is that a good solution?

Thanks

Stefan
Garrett Rowe
Ranch Hand

Joined: Jan 17, 2006
Posts: 1296
If it works then it's a "Good Thing" however you should note that index based access of LinkedList elements are not as efficient as index based access of ArrayList elements, so your algorithms for the LinkedList based implementation will not be as performant. Iterator based algorithms might be better,


Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them. - Laurence J. Peter
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem Interface/Abstract/Collections