Java System ClassThe System class of java contains several useful class fields and methods. It also provides facilities like standard input, standard output, and error output Streams. It can't be instantiated. The Java System class comes in the module of "java.base" & in the package of "java.lang". In Java System Class, we have 3 different types of field and 28 different types of method. Java System Class consists of following fields:- SN | Modifier and Type | Field | Description |
---|
1 | static PrintStrean | err | The "standard" error output stream. | 2 | static InputStream | in | The "standard" input stream. | 3 | static PrintStream | out | The "standard" output stream. |
Java System class Methods:Java System Class consists of following methods:- SN | Method | Description |
---|
1 | arraycopy(object src, int srcPos, object dest, int destPos, int length) | This method copies subsequence components of a specified source array to the specified destination array. | 2 | clearProperty(String key) | This method removes the system property indicated by the specified key. | 3 | console() | This method returns the Console object only if any Console object is associated with the java virtual machine. | 4 | currentTimeMillis() | This method returns the current time in the format of a millisecond. Millisecond will be returned as a unit of time. | 5 | exit(int status) | This method terminates the current Java virtual machine running on the system. This method takes the status code as an argument. | 6 | gc() | This method runs the garbage collector | 7 | getenv() | This method returns a string map view of the current system environment. Here string map is unmodifiable, and the environment is system dependent. | 8 | getLogger(String name, RecourseBundle bundle | This method returns the localizable instance of a logger. Further, this instance can be used for caller's use. | 9 | getLogger(String name) | This method returns an instance of a logger. Further, this instance can be used for caller's use. | 10 | getenv(String name) | This method returns the value of environment variable which is specified and system dependent external named value. | 11 | getProperties() | This method returns the properties of the current system. Here properties are the properties that our JVM gets from our operating system | 12 | getProperty(String key) | This method returns the property of a system which is indicated by a specified key. | 13 | getProperty(String key,String def) | This method returns the property of a system which is indicated by a specified key. | 14 | getSecurityManager() | This method returns an interface of System Security. | 15 | identityHashCode(Object x) | This method returns hash code for the specified object. It is returned by the default method hashCode(). | 16 | inheritedChannel() throws IOException | This method returns channel inherited from an entity that created this Java virtual machine. | 17 | lineSeparator() | This method returns line separator string which is system dependent. It returns the same value every time. | 18 | load(String filename) | This method loads file specified by the filename argument. Here argument must be an absolute path name. | 19 | mapLibraryName(String libname) | This method maps a library name into the platform-specific string which represents a native library. | 20 | nanoTime() | This method returns high-resolution time source in nanoseconds of running Java virtual machine. It returns the current value of JVM. | 21 | runFinalizersOnExit(boolean value) | This method runs finalization methods which can be of any objects pending finalization. | 22 | runFinalization() | This method runs finalization methods which can be of any objects pending finalization. | 23 | setErr(PrintStream err) | This method reassigns the "standard" error output stream. | 24 | setIn(PrintStream in) | This method reassigns the "standard" input stream. | 25 | setOut(PrintStream out) | This method reassigns the standard output stream. | 26 | setSecurityManager(SecurityManager s) | This method sets the system security. | 27 | setProperties(Properties props) | This method sets the properties of the system to the argument of properties. | 28 | setProperty(String key, String value ) | This method sets the property of a system which is indicated by a key. |
Example 1Output: Source array:ABBHAM
Destination array:SHUNUL
Source Position:2
Destination Position:3
Length:4
Destination array after use of arraycopy()
SHUBHAMJADON
Example 2Output: Current time in millisecond
1532262046724
Example 3Output: Example 4Output: Current time in nanoseconds = 1316893720017448
Example 5Output: identity hash code of object a = 843730481
identity hash code of object b = 743673026
Example 6Output: Your System property for user
shubham
C:\Users\Shubham Jadon
C:\Users\Shubham Jadon\eclipse-workspace\tpoint
Example 7Output: Example 8Output: map library for OS's name = os.name.dll
map library for OS's architecture = os.arch.dll
map library for OS's version = os.version.dll
|