Hi there,

so I'm currently studying Java at my University and as of right now we're working on Linked Lists, Array lists, Array Deques, etc. As part of this lesson, we're being told to write our own versions, both recursive and iterative, of the predefined java functions for its corresponding data structure (such as addLast, contains, removeLast, etc).

I am finding this to be a little difficult as I tend to struggle with what the optimal logic would look like, but I was wondering in what situations would I be in where I would every need to create my own version as opposed to just using the predefined functions? Is this a common course of action?

I know that we're being taught this in order to have a better understanding of the logic behind the data structures, but I am just curious as to where I would absolutely need to edit the base Java functions for specific use.

Thank you!

EDIT: Just noticed the spelling error in the title. How embarrassing!

Edited by Syrne: n/a

5 Years
Discussion Span
Last Post by hfx642
Featured Replies

In real life its rare to very rare that you write your own versions of Java API classes like those. Even if there is some small optimisation you could do for some highly specific application, you would have to offset that against the disadvantages of using "roll your own" code rather than the highly designed, tested, documented, supported API versions.

Obviously, as training exercises they are really good - lots of methods and arrays and thread-related issues to learn about and practice - plus there's no need to spend ages defining and understanding some artificial problem description.

What speling misteak?


Thanks for the info!

And the mistake was "Javan" in the title. :P


Fixed title; you can always try to get the title edited by "flagging" it as bad post.


I've never had the need to rewrite predefined functions.
But rewriting redefined components, is a different story.
I have found it neccessary to write my own "JSpinner".
And, this week, I plan to write my own "VCR type" controler panel.
I'm sure there are some out there,
but I havent found any that are as flexible/reusable as I would like.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.