Alternatively,
You can use a "while(true)" loop and use break and continue statement with in your loop ..as in the following example.
import java.io.*;
class ToContinue
{
public static void main(String ar[])
{
while(true)
{
try{
System.out.println("Enter a number");
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
String str= bf.readLine();
int val=Integer.parseInt(str);
System.out.println("The value is" + val);
System.out.println("Want to Continue");
BufferedReader bf1 = new BufferedReader(new InputStreamReader(System.in));
String str1= bf1.readLine();
if(str1.equals("yes"))
continue;
else
break;
}
catch(IOException ioe)
{}
}
}
}
|