wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes Required Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Required Help" Watch "Required Help" New topic
Author

Required Help

Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36
Hi Everyone ,

Can anyone help me finding the bug in the following piece of code ?

---------------------------------------------------------------------------

Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61095
    
  66

I modified your subject a bit as a favor. Demanding immediate help is not only rude, it's counter-productive. Please read this: EaseUp.

Also, please read this: UseAMeaningfulSubjectLine. A better subject line will attract more volunteers who can help you.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1660
    
  11

What is the code doing or not doing that isn't expected? Just saying that something doesn't work isn't really too descriptive.

Are you able to compile? Are you getting a runtime error? Is it working, but not as expected?

What kinds of error messages are you getting?


When you do things right, people won't be sure you've done anything at all.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

The method should find the nextentry of list, but it does not do so.

I couldn't really figure out why or how to fix that , when this is the only problem.

Remaan Rem
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1660
    
  11

If you're sure there's something in the list to get, it's probably something wrong with your loop logic.

You might want to seperate the incrementing of the currentIndex from the get() method for the list. In other words, increment at the very end, after everything else in that loop is done.

That may help narrow down the problem.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36
I am not sure I get what you mean ..

Do you mean I shall use a while loop, where the increamenting happens inside of the the loop rather than the header ?

What do you think ?
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1660
    
  11

Instead of this:



Choose this:



The top one increments the variable before it's used, which can cause problems. By separating the usage and the increment, you may fix your issue.
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36


Ya .. Bu even doing what you said changes the task alittle bit ..

We want to get the element at this index after increamenting it ..

What do you think >
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1660
    
  11

So you never touch the entry at the currentIndex?
Remaan Rem
Ranch Hand

Joined: Mar 04, 2010
Posts: 36

It should look like that >

as this is a given piece of code ..

Anyways , I tried your suggestion , without a benefit.

And, eventually submitted the Assignment on that shape ..

Thanks alot for your help .. and have a nice day Janeice

Remaan
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Required Help