Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Required Help

 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Everyone ,

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

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

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64833
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Janeice DelVecchio
Saloon Keeper
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 1809
12
Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you never touch the entry at the currentIndex?
 
Remaan Rem
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic