Results 1 to 4 of 4

Thread: what's the syntax to end java program?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2002
    Posts
    103

    what's the syntax to end java program?

    in C it was something like return 0;
    return 0;
    right? what about java (to end program when user inputs the letter 'q'?

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    Code:
    System.exit(0);
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    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.

  4. #4
    Dazed Member
    Join Date
    Oct 1999
    Location
    Ridgefield Park, NJ
    Posts
    3,418
    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);}   
      }
     }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width