• 0

Calling lines of code within JAVA


Question

hey everyone,

when you are in java, can u tell it to go directly to a specfic line?

eg

say i was on line 50 and i wanted to tell the program to execute and carry on the code from line 42... can i do this?

i want to be able to tell it to go back a bit, so if i was on line 50, i could tell it to go to line 42, execute it, then continue on to 43 then 44 and so forth.

can this be done?

thanks

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

hey,

no thats just the thing... its an error check... if the user enters an invalid number half way through the method, i dont want to send them all the way to the start again.... i just want to be able to let them know that what they entered was wrong and let them re-enter it...

would it help if i appened the code i am trying to work out?

thanks

Link to comment
Share on other sites

  • 0

Then write code to show a message saying they entered an invalid number :huh:

Or better yet, don't do validation until the whole number is entered (Y) Then you can validate the entire field and you don't have to add extra code...

Link to comment
Share on other sites

  • 0

ok, im using a loop because it works out easier, but it doesnt work properly... please help\

this is the code :

do

{

System.out.print("Enter the term of your loan (1 - 25 years): ");

iTimeLoan = MyInput.readInt();

}

while

((iTimeLoan < 1) && (iTimeLoan > 25));

System.out.println("Please enter a term between 1 - 25 years");

if the user enters a number between 1 - 25, it continues on with the code (which i didnt add), however, if they enter otherwise, it will ask them to enter the number again.

where did i go wrong?

thanks

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.