How to quit (exit) from within the program in Java

1 Answer

0 votes
package javaapplication1;
 
public class JavaApplication1 {
 
    public static void main(String[] args) {
        
        System.out.println("abc");
        
        System.exit(0); // everything ok
        
        System.out.println("xyz");
    }
}
 
/*
run:
 
abc
 
*/

 



answered Sep 5, 2016 by avibootz

Related questions

2 answers 276 views
276 views asked Mar 21, 2021 by avibootz
1 answer 306 views
1 answer 332 views
1 answer 183 views
183 views asked Jun 24, 2025 by avibootz
1 answer 179 views
1 answer 181 views
181 views asked Jun 23, 2025 by avibootz
1 answer 167 views
167 views asked Jun 23, 2025 by avibootz
...