• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Function not taking int value

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi -
I have a very strange error.
I am calling this code within a JSP.
for(int i=index; i<(index + increment); i++)
{
RecordBean record = recordListBean.get(i);

}

All I would like to do is get the record at index 'i'in the function " RecordBean record = recordListBean.get(i); "
I get an error page if I do this (don't know the exact error message), however - if I create an " int j=4; ", for example and use RecordBean record = recordListBean.get(j);
- this works just fine.
I tried to "trick" the code and assigned "int j = i; " within the loop. It recognized this and errored on me again.
Why can this function take in one int variable and not another?
I'm very confused.
Please help.
Thanks in advance.
-Gale
 
Ranch Hand
Posts: 3451
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Gale,
This is only a hunch, but since you start your loop with:

My guess is that i or index or increment or some interaction of the three is what the problem is. Perhaps when you call recordListBean.get(i) that i is invalid. You need to look closely at the exception that is thrown to locate whatever is causing the problem.
Michael Morris
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic