I've done some research to know if there is an equivalent to PHP die in java
Sometimes I'm doing small tests and I really want to stop my code at specific line , and return doesnt stop the code like "die" in php
Is there a die quivalent in java?
Use System. exit(0); to exit the java code. Keep a note this will stop the JVM instance which is currently running.
jQuery die() Method The die() method removes one or more event handlers, added with the live() method, for the selected elements.
The die() function prints a message and exits the current script. This function is an alias of the exit() function.
What is the difference between echo and die() or are they same? The die() function can accept an optional argument string that it will output just before terminating the script. echo() only outputs its arguments, it will not terminate the script.
Use System.exit(0);
to exit the java code.
Keep a note this will stop the JVM instance which is currently running.
If you want to come out of a method use return or throw exception to showcase error condition.
try:
System.out.println(message);
System.exit(0);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With