in C it was something like return 0; return 0; right? what about java (to end program when user inputs the letter 'q'?
Code: System.exit(0);
System.exit(0);
Laugh, and the world laughs with you. Cry, and you just water down your vodka. Take credit, not responsibility
Or return from the main function just like in C.
All the buzzt CornedBee "Writing specifications is like writing a novel. Writing code is like writing poetry." - Anonymous, published by Raymond Chen Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
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);} } } }
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);} } } }
Java CodeBank Entries >> Parsing URL's| Collections/ShuffleElements | Threads isAlive() | Daemon Threads |Remote Class Loading | Sorted Keys (Map) | Backwards List | Thread States | Collections/Arrays Generics | Regular Expression(Grouping and Capturing) | Properties | JLabel/JTextField Combo | Reading Request Parameter Values | Host Lookup | Setting the size of a JFrames inner-region | GUI Native L&F
Forum Rules