jQuery in Action, 3rd edition
The moose likes Beginning Java and the fly likes AddAfter method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "AddAfter method " Watch "AddAfter method " New topic

AddAfter method

Jere Johnson

Joined: Mar 29, 2003
Posts: 28
I need help figuring out how to add an element after an existing element in an array. The isCurrent boolean checks to see if there is a current element. I almost have it. I need someone to show me what im missing. Thanks,

[ October 03, 2003: Message edited by: Jere Johnson ]

Diapers are the best invention
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Hi, Jere -
I don't know what problem the code is giving you, but I would recommend checking for the end of the array to avoid the ArrayIndexOutOfBounds exception.
Also, I'm assuming "manyItems" is your element count?
I also see a mismatched number of curly braces. The method addAfter() is not closed.
Maybe if you provide a little more context, like the class this method belongs to and its method signatures, I could be of further help.

Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4, SCJD in progress, if you can call that progress...)
Jeff Bosch
Ranch Hand

Joined: Jul 30, 2003
Posts: 805
Another quick point:
I would explicitly test for the boolean "true": if ( isCurrent() == true ).
Then, you don't really need "else if" because you've already done the test. The else-if can be reduced to a simple else{} block.
I agree. Here's the link: http://aspose.com/file-tools
subject: AddAfter method
It's not a secret anymore!