Logo 
Search:

Java Articles

Submit Article
Home » Articles » Java » FundamentalRSS Feeds

System Class in Java

Posted By: Jalal Bashara     Category: Java     Views: 3116

This article explains about System class in java with example.

System class defines several attributes related to the run-time environment.

   Static variable in System Class

Variable

  Description

static PrintStream err

 

The "standard" error output stream.

static InputStream in

 

The "standard" input stream.

static PrintStream out

The "standard" output stream.

 

Static methods in System Class

 

 Method

Description 

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. 

static String clearProperty(String key) 

Removes the system property indicated by the specified key. 

static Console console() 

Returns the unique Console object associated with the current Java virtual machine, if any. 

static long currentTimeMillis()  

Returns the current time in milliseconds. 

static void exit(int status)  

Terminates the currently running Java Virtual Machine. 

static void gc() 

Runs the garbage collector. 

static Map<String,String> getenv()  

Returns an unmodifiable string map view of the current system environment. 

static String getenv(String name)  

Gets the value of the specified environment variable. 

static Properties getProperties()  

Determines the current system properties. 

static String getProperty(String key)  

Gets the system property indicated by the specified key. 

static String getProperty(String key, String def)  

Gets the system property indicated by the specified key. 

static SecurityManager getSecurityManager() 

Gets the system security interface. 

static int identityHashCode(Object x)  

Returns the same hash code for the given object as would be returned by the default method hashCode(), whether or not the given object's class overrides hashCode().

static Channel inheritedChannel()  

Returns the channel inherited from the entity that created this Java virtual machine. 

static void load(String filename)  

Loads a code file with the specified filename from the local file system as a dynamic library.

static void loadLibrary(String libname)  

Loads the system library specified by the libname argument. 

static String mapLibraryName(String libname)  

Maps a library name into a platform-specific string representing a native library. 

static long nanoTime()  

Returns the current value of the most precise available system timer, in nanoseconds. 

static void runFinalization()  

Runs the finalization methods of any objects pending finalization. 

static void runFinalizersOnExit(boolean value)  

Deprecated. This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock. 

static void setErr(PrintStream err)  

Reassigns the "standard" error output stream. 

static void setIn(InputStream in)  

Reassigns the "standard" input stream. 

static void setOut(PrintStream out)  

Reassigns the "standard" output stream. 

static void setProperties(Properties props)  

Sets the system properties to the Properties argument. 

static String setProperty(String key, String value)  

Sets the system property indicated by the specified key. 

static void setSecurityManager(SecurityManager s) 

Sets the System security.



Example of System Class

Example 1 : Program that displays use of System Class

class SystemClassDemo
{
  public static void main(String args[])
  {
int arr1[] = {1,2,3,4,5};
int arr2[] = {0,0,0,0,0};
System.out.print("Content of array 2 before copy : ");

for(int i = 0; i < arr2.length; i = i + 1) 
   System.out.print(arr2[i]);  
   System.out.print(" ");
}

System.arraycopy(arr1,0,arr2,0,5);

System.out.println("Content of array 2 after copy : ");

for(int i = 0; i < arr2.length; i = i + 1) 
   System.out.print(arr2[i]);  
   System.out.print(" ");
}
  }
}


Output
Content of array 2 before copy : 0 0 0 0 0
Content of array 2 after copy : 1 2 3 4 5
  
Share: 

 
 
 

Didn't find what you were looking for? Find more on System Class in Java Or get search suggestion and latest updates.

Jalal Bashara
Jalal Bashara author of System Class in Java is from Hyderabad, Pakistan.
 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!