Skip to main content Skip to docs navigation
TechSpiderTutorials

Java.lang.System class in Java

On this page

System class

Among the facilities provided by the System class are standard input, standard output, and error output streams; access to externally defined properties and environment variables; a means of loading files and libraries; and a utility method for quickly copying a portion of an array.

The System class contains several useful class fields and methods. It cannot be instantiated.

Method arraycopy()

public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)

Copies an array from the specified source array, beginning at the specified position, to the specified position of the destination array. A subsequence of array components are copied from the source array referenced by src to the destination array referenced by dest. The number of components copied is equal to the length argument. The components at positions srcPos through srcPos+length-1 in the source array are copied into positions destPos through destPos+length-1, respectively, of the destination array.

System class Example:

public class ArrayCopyDemo
{
    public static void main(String[] args) 
    {
        char[] copyFrom = { 'T', 'e', 'c', 'h', 's', 'p', 'i',
			    'd', 'e', 'r', ' ', 'T', 'u','t','o','r','i','a','l','s' };
        char[] copyTo = new char[17];

System.out.println("Original String is...:"+new String(copyFrom));
        System.arraycopy(copyFrom, 4, copyTo, 0, 16);
        System.out.println("Copied String...:"+new String(copyTo));
    }
}
Original String is...:Techspider Tutorials
Copied String...:spider Tutorials