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 168 views
168 views asked Mar 21, 2021 by avibootz
1 answer 216 views
1 answer 232 views
1 answer 88 views
88 views asked Jun 24, 2025 by avibootz
1 answer 99 views
1 answer 94 views
94 views asked Jun 23, 2025 by avibootz
1 answer 91 views
91 views asked Jun 23, 2025 by avibootz
...