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 280 views
280 views asked Mar 21, 2021 by avibootz
1 answer 309 views
1 answer 334 views
1 answer 184 views
184 views asked Jun 24, 2025 by avibootz
1 answer 181 views
1 answer 184 views
184 views asked Jun 23, 2025 by avibootz
1 answer 172 views
172 views asked Jun 23, 2025 by avibootz
...