System.out.println in Java and How it works

System.out.println() is the most used statement in the java language.In this java tutorial we will learn what is System.out.println() and how it works. It is one of the most executed statement in the history of java. We shortly call it SOP. What is System.out.println() this question has been asked many times in java interviews.


What is System.out.println

In simple words, System.out.println is a java statement that prints the argument passed, into the System.out which is generally stdout.

  • System - is a final class in java.lang package.According to Oracle docs: "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".
  • Java Collections Framework Tutorial

    Collections in java are used in almost every enterprise application. Java Collections framework consists of interfaces and classes which helps in storing and processing the data efficiently. Java Collections Tutorial will look into each of the classes.

    Read Also :  Collections in Java Interview Questions 

    Java Collections Interfaces and Classes


  • Collection Interface
  • HashSet Class in Java Tutorial with Example

    Java HashSet class implements Set interface. It has the following properties.

    1. HashSet does not allow duplicates, means it contains unique elements.
    2. HashSet is unordered meaning it does not guarantee that the order will remain constant over time.
    3. HashSet is backed by Hashtable (actually a HashMap instance).
    4. HashSet permits the null elements.
    5. HashSet implementation is not synchronized. It can be synchronized externally.
        Set s = Collections.synchronizedSet(new HashSet(...));
    6. Iterators returned by HashSet class is fail- fast.

    HashSet Example

    TreeMap Class in Java Tutorial with Example

    TreeMap class implements the Map interface.It extends AbstractMap class and implements NavigableMap interface. It has the following properties:

    1. TreeMap sorts the keys according to the natural ordering of its keys, or by Comparator provided at  map creation time.
    2. TreeMap is a red black tree based NavigableMap implementation.
    3. TreeMap implementation provides guaranteed log(n) time cost for the containsKey,get,put and remove operations.
    4. TreeMap does not allow null keys and null values.
    5. TreeMap is not synchronized.It must be synchronized externally
        SortedMap  m = Collections.synchronizedSortedMap(new TreeMap(...));

    TreeMap Example


    TreeSet Class in Java Tutorial with Example

    TreeSet class implements Set interface. It extends AbstractSet class and implements NavigableSet interface.It has the following properties:

    1. TreeSet implements Set interface so it does not allow duplicate values.
    2. TreeSet sorts the elements in the ascending order.
    3. TreeSet does not allow to insert heterogeneous elements. ClassCastException will be thrown if you try to add a heterogeneous element.
    4. TreeSet doesn't allow to add null element.
    5. TreeSet implementation is not synchronized. It can be synchronized explicitly by using
        SortedSet  s = Collections.synchronizedSortedSet(new TreeSet(...);
    
    


    TreeSet Example


    -->