All About Class System in Java

0
16
Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Class System in Java
Class System in Java

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.System class provides the methods that provide platform independent interface to system functionality.

The structure of Class System in Java is given as:


public final class java.lang.System extends java.lang.Object{
//Member elements:
public static final 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 final PrintStream err;
//This corresponds to standard error Stream.
public static final PrintStream 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 native void arrayCopy(Object Array_Src,int src_position,
Object Array_Dest,int dest_position,int length);
public static native long currentTimeMills();
public static void exit(int status);
public static void gc();
public static Properties getProperties();
public static String getProperty(String key);
public static String getProperty(String key,String def);
public static String getenv(String name);
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);
public static native int identityHashCode(Object obj);
public static void runFinalizersOnExit(boolean value);
public static void setErr(PrintStream err);
public static void setIn(InputStream in);
public static void setOut(PrintStream out);
}

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.

Don't miss out!
Subscribe To Newsletter

Receive top technical news, lesson ideas, travel tips and more!

Invalid email address
Give it a try. You can unsubscribe at any time.

Spread the love
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

LEAVE A REPLY

Please enter your comment!
Please enter your name here