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 283 views
283 views asked Mar 21, 2021 by avibootz
1 answer 311 views
1 answer 336 views
1 answer 185 views
185 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
...