in C it was something like return 0;right? what about java (to end program when user inputs the letter 'q'?Quote:
return 0;
Printable View
in C it was something like return 0;right? what about java (to end program when user inputs the letter 'q'?Quote:
return 0;
Code:System.exit(0);
Or return from the main function just like in C.
Code:import java.io.*;
public class X{
public static void main(String[] args){
BufferedReader buff = new BufferedReader(
new InputStreamReader(System.in)
);
String s = null;
for(;;){
try{
System.out.println("Input Values");
// blah blah blah
System.out.println("q to exit");
s = buff.readLine();
if(s.equals("q") || s.equals("Q")) break;
}catch(IOException e){System.err.println(e);}
}
}
}