The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

Unable to execute the program (no compilation error)

Dear experts,

I am doing my assignment on finding how many numbers in N digit satisfy K requirement.
However, when i am testing the code, i could compile it but i couldn't execute it.
I am wondering if i made mistake in the

x = result + y; // add them together and return it.

as when i comment this out, my program is able to execute,though i didn't get the right output value
Please kindly enlighten me.

Re: Unable to execute the program (no compilation error)

Hello Alexie91,

I don't see where x would ever be less than 0 and thus you have an infinite loop. If the condition x>0 was to check if N was positive then I would suggest doing that before you even get to the loop. Really, this whole thing doesn't make much sense to me, if you can explain a little more about the assignment that may help.