I have a piece of coding I am working on for an assignment for uni and in truth I’m not that great with Java, but I have tried. I’m trying to get my try catch to work but it never seems to do what it is suppoes to. I think I have the exception wrong but I’m not sure which exception to use for the problem as I am trying to stop letters being typed in and just numbers.
The final problem I am having is I don’t know where to put this piece of coding:
{
while (true)
{
cancel();
}
}
I’m not sure in which part it is suppoes to go.
Any help would be greatly appricated.
This is my code, I’m sorry if it is a little messy.
Coding
Your code is very verbose – most of the comments are unnecessary (even though you may be urged to include them) So instead of:
You could write:
When you have tidied the code it will be much easier to see the logic.