Adrian Adriano Adrian Adriano - 1 month ago 11
Java Question

is there any goto command or continue command for If statement ??? JAVA

im just wondering is there any goto or continue commands for if statement ??
im using continue; but its not working on if statement.

if ( typess == 1){
***OUTER:***

System.out.println("Type: Current Minimum of 1000.00 ");
System.out.print("Amount: " );
currenttype = Float.parseFloat(in.readLine());
if ( currenttype >= 1000 ){
balance += currenttype;
System.out.print("Successful " + currenttype + " Added to your Account");

}

else
{
**continue OUTER;**
System.out.print("MINIMUM IS 1000.00 ");

}

Answer

There is such posibility, but you should use do-while loop instead, e.g.

boolean printMsg = false;
do {
    if (printMsg) {
        System.out.print("MINIMUM IS 1000.00 ");
    }
    printMsg = true;
    System.out.println("Type: Current Minimum of 1000.00 ");
    System.out.print("Amount: " );
    currenttype = Float.parseFloat(in.readLine());
} while (currenttype < 1000);

balance += currenttype;
System.out.print("Successful " + currenttype + " Added to your Account");