All About Class System in Java


The System class contains a number of useful methods and member elements. As all the members of the System class are static in nature, we do not need to instantiate this class. We can directly call them By using System.(memberName) like-System.in or System.out etc.

public final class java.lang.System extends java.lang.Object{
//Member elements:
public static InputStream in;
// This is the standard inputStream and it is already opened by JVM. It is ready to supply input data. This stream takes input from keyboard.But this can be configured to take input from any other source.
public static PrintStream err;
//This corresponds to standard error Stream.
public static OutputStream out;
//This is the standard output stream and it is already opened to provide output data.This stream prints output to display or console but can be configured to other output destination.
//Methods:
public static void arrayCopy(Object Array_Src,int src_position,Object Array_Dest,int dest_position,int length);
public static long currentTimeMills();
public static void gc();
public static Properties getProperties();
public static String getProperty(String key);
public static String getProperty(String key,String def);
public static SecurityManager getSecurityManager();
public static void load(String fileName);
public static void loadLibrary(String fileName);
public static void runFinalization();
public static void setProperties(Properties prop);
public static void setSecurityManager(SecurityManager sm);
}
 
Example:
System.out.Prinln() method writes a line to to console as output data. The System.out corresponds to the OutputStream as described above and does not need to instantiate the System class. As they are static we can directly call them. pritln() method is defined in the PrintStream class.
All About Class System in Java All About Class System in Java Reviewed by Animesh Chatterjee on September 17, 2018 Rating: 5

No comments:

Powered by Blogger.