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 301 views
1 answer 330 views
1 answer 181 views
181 views asked Jun 24, 2025 by avibootz
1 answer 176 views
1 answer 181 views
181 views asked Jun 23, 2025 by avibootz
1 answer 165 views
165 views asked Jun 23, 2025 by avibootz
...