how to exit a java program with a message code example Example: how to exit a java program System.exit(0);