Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

implement own ArrayList ?

 
kri shan
Ranch Hand
Posts: 1467
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can i implement my own ArrayList instead of using java.util.ArrayList ?
 
Timmy Marks
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What problem are you having? If you're just looking for source code for it, you might as well use the source from Sun!
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sounds like a homework assignment... Often those include things like "write your own <whatever>" even if such already exists.

Yes, you can write your own.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If your assignment is to create your own, start with the JavaDoc that describes it as "Resizable-array implementation of the List interface." Make an empty class that "implements List" and the compiler will tell you (in the form of error messages) what methods you need to write. Look at the doc for List to see what they all do. Some are optional and depending on your aassignment you may be able to throw UnsupportedOperation exception for any you don't get to.

It would proabably be cheating to extend AbstractList.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic