Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using System.exit() to call another method within the same class

Is there any reason why I should avoid calling methods in System.exit() like in the example code below?

public class RBS {

    int processClients() {
        ...
        return 0;
    }

    public static void main(String[] args) {
        RBS myBank = new RBS("Royal Bank of Scotland");
        System.exit(myBank.processClients());
    }
}
like image 419
Edward Reid Avatar asked Jul 17 '26 07:07

Edward Reid


1 Answers

The java.lang.System.exit() method terminates the currently running Java Virtual Machine.

the declaration for java.lang.System.exit() method

public static void exit(int status)//Should be an int value. 

where status -- This is the exit status.

here you are using value of your method means myBank.processClients(). So exit value is return value 0 of the above method

For more

like image 173
SatyaTNV Avatar answered Jul 18 '26 20:07

SatyaTNV



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!