File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes what is wrong in this code ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Customer Requirements for Developers this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "what is wrong in this code ?" Watch "what is wrong in this code ?" New topic

what is wrong in this code ?

Ranch Hand

Joined: Nov 08, 2000
Posts: 52
i have been getting an error while i am running this code
on the line where the count varaible is incremented .Please ket me know
Elizabeth Lester
Ranch Hand

Joined: Aug 14, 2001
Posts: 129
What is the error you are getting?
Rob Ross

Joined: Jan 07, 2002
Posts: 2205
It's impossible to say with the code snipet you have provided. If I just try to copy your code as is, NONE of your variables have any declared types, so the compiler complains about all of them. But I don't know if this is your problem because I don't know if or how you have declared your variables. Please post your code in the complete context, so it compiles, then I can answer you better.

SCJP 1.4
Jim Yingst

Joined: Jan 30, 2000
Posts: 18671
At a guess though, chances are good that you're getting an ArrayIndexOutOfBoundsException from c[m], since there doesn't appear to be bounds checking on this. (Unless j+1 is the size of array c.) You might want to put proper bounds checking into the loop:
for(m = 1; m < j + 1 && m < c.length; m++)
Incidentally, arrays start at index 0, not 1, so there's a good chance you want to start with m = 0 rather than m = 1.

"I'm not back." - Bill Harding, Twister
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
subject: what is wrong in this code ?
It's not a secret anymore!