What is the purpose of the System class?
1. System class is provided with useful fields (static members) pertaining to the environment.
2. 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
3. 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.
4. The System class can not be instantiated.
5. The System class contains several useful class fields and methods.
6.
Some System class features are:- Standard input
- Standard output
- Error output streams
- Access to externally defined "properties"
- A means of loading files and libraries
- A utility method for quickly copying a portion of an array
7. The System class cannot be instantiated.