The System class in Java is part of the java.lang package.
It provides useful methods and fields for input, output, memory management, time, and system-related operations.
The System class is final and all its members are static. So, we do not need to create an object of it.
The println() method prints output to the console and moves the cursor to the next line.
The print() method prints output but does not move to the next line.
The err is used to print error messages.
The in is used to take input from the user (usually with Scanner class).
The currentTimeMillis() method returns the current time in milliseconds.
The nanoTime() method returns the current time in nanoseconds. It is used to measure execution time.
The exit() method stops the program execution.
0 means normal termination.
The gc() method requests the Java Virtual Machine to run Garbage Collection.
The getenv() method returns system environment variables.
The getProperty() method returns system properties.
The System class is one of the most important classes in Java.
It provides essential methods like print(), println(), exit(), currentTimeMillis(), and more.
Every Java program uses the System class in some way.