What is the purpose of the System class?
System class is provided with useful fields (static members) that are pertaining to the environment.
Standard input/output and error output streams are provided with System class. These are used to access the externally defined properties and environment variables.
Example:
System.in - external property for input device.
System.out – external property for output device
Other useful methods that interact with external system / environment are:
-
currentTimeMillis() – Returns the current time in milliseconds
-
exit() - Terminates currently running JVM
-
gc() - Invokes the garbage collector
-
getProperties() - Returns the system properties.
The System class can not be instantiated.