Java System nanoTime() Method7 Nov 2024 | 1 min read The nanoTime() method of Java System class returns high resolution time source in nanoseconds of running java virtual machine. It returns the current value of JVM. SyntaxReturnsReturns a high resolution time source in nanoseconds. ExampleOutput: Current time in nanoseconds = 1316893720017448 Next TopicJava-system-runfinalization-method |
The setOut() method of Java System class is used to reassign the standard output stream. Syntax: public static void setOut(PrintStream out) Parameters: out - new standard output stream. Throws: SecurityException: This exception will throw if security manager exists and its checkPermission method doesn't allow reassigning of the standard outputstream. Example import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import...
1 min read
The clearProperty() method of Java System class removes the system property indicated by the specified key. Syntax public static String clearProperty(String key) Parameters Key - Removes the name of System property Returns The ious string value of the system property. If there was no property with that key then it will return null. If...
1 min read
The setProperty() method of Java system class sets the property of the system which is indicated by a key. Syntax: public static String setProperty(String key, String value ) Parameters: key - It is the name of the system property. value - It is the value of the system property. Returns This method returns...
1 min read
The getProperty(String key,Stringdef) method of Java System class returns property of a system which is indicated by a specified key. Syntax public static String getProperty(String key,String def) Parameter key - the name of the system property. def - a default value. Returns This method returns System property or default value if there is...
1 min read
The identityHashCode() method of Java System class returns hash code for the specified object. It is returned by the default method hashCode(). Syntax public static int identityHashCode (Object x) Parameter x - object for which the hashCode is to be calculated Returns Returns the hash code. Returns zero as reference if hash code...
1 min read
The setErr() method of Java System class is used to reassign the "standard" error output stream. Syntax public static void setErr(PrintStream err) Parameter err - It is the new standard error output stream. Exception: SecurityException: This exception will throw if the security manager exists and its checkPermission method doesn't allow reassigning of the...
1 min read
The exit() method of System class terminates the current Java virtual machine running on system. This method takes status code as an argument. Status - exit(0) - indicates Successful termination Status - exit(-1) - indicates unsuccessful termination with Exception Status - exit(1) - indicates Unsuccessful termination Syntax public static void exit(int...
1 min read
The mapLibraryName() method of Java System Class maps a library name into platform-specific string which represents a native library. Syntax public static String mapLibraryName(String libname) Parameter libname - the name of the library. Returns Returns a native library name which is platform-dependent. Returns NullPointerException if libname is null. Example 1 public class SystemMapLibraryNameExample1 { public static...
1 min read
The currentTimeMillis() method of System class returns current time in format of millisecond. Millisecond will be returned as unit of time. Syntax public static long currentTimeMillis() Returns Returns difference, measured in milliseconds, between current time and midnight January 1, 1970 UTC(coordinated universal time). Example public class SystemCurrentTimeMillisExample1 { public static void main(String[] args)...
1 min read
The inheritedChannel() method of Java System class returns channel inherited from entity that created this java virtual machine. Syntax public static Channel inheritedChannel() throws IOException Returns Returns the inherited channel. Returns null if channel is not there. If an I/O error occurs then IOException is thrown. If Security manager exist and doesn?t allow...
1 min read
We request you to subscribe our newsletter for upcoming updates.
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India