Difference between System.exit and assert, in Java

System.exit(int) is a method in java.lang package, where as assert is a keyword.

assert is used for debugging purpose, and assert to work, explicit enabling is required by providing -ea JVM argument. When assert expression gets evaluated to false, AssertionError exception is thrown.

For System.exit() to execute, no such explicit enabling is required. When System.exit() is executed, program terminates by providing exit code to Operating System.

Below is declaration of System.exit() method

public static void exit(int status_code);

System.exit() is generally used with below arguments
System.exit(0) – indicates that java program terminated normally
System.exit(1) – indicates that java program terminated abnormally
System.exit(-1)- indicates that java program terminated abnormally

Below is an example for System.exit()

public class SystemExitDemo {
public static void main(String args[])
	String str="2sdjhfgsdjhfgsdjh3";

	int i = Integer.parseInt(str);

	}catch(Exception e)
	System.exit(1);//abnormal termination
	System.exit(0);//normal termination

You may also like to read:
What are data Wrapper classes in Java?
What is non static block, when to use it?
How to use assert
Purpose of System.getProperty() method