Wednesday, 19 November 2014

Java : Collection Framework : StringTokenizer (Default Delimiter)


Click here to watch in Youtube :
https://www.youtube.com/watch?v=8btSCVPfcSw&list=UUhwKlOVR041tngjerWxVccw

StringTokenizerExample.java
import java.util.StringTokenizer;

public class StringTokenizerExample
{

    public static void main( String[] args )
    {
        String strValue = "Peter is playing football";

        StringTokenizer stringTokenizer = new StringTokenizer(strValue);

        /*
         * Calculates the number of times that this tokenizer's nextToken method
         * can be called before it generates an exception. The current position
         * is not advanced.
         */

        System.out.println("Total Token Count :" + stringTokenizer.countTokens()
                + "\n");

        int i = 1;

        /*
         * Tests if there are more tokens available from this tokenizer's
         * string. If this method returns true, then a subsequent call to
         * nextToken with no argument will successfully return a token.
         */

        while( stringTokenizer.hasMoreTokens() )
        {
            /*
             * Returns the next token from this string tokenizer.
             */
            String token = stringTokenizer.nextToken();
            System.out.println("Token " + i + " : " + token);
            ++i;
        }

    }
}
Output
Total Token Count :4

Token 1 : Peter
Token 2 : is
Token 3 : playing
Token 4 : football
To Download StringTokenizerDemoDefaultDelim Project Click the below link
https://sites.google.com/site/javaee4321/java-collections/StringTokenizerDemoDefaultDelim.zip?attredirects=0&d=1

See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : StringTokenizer (Introduction)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=ah5bVEJpQ38&list=UUhwKlOVR041tngjerWxVccw

    Click the below Image to Enlarge
    Java : Collection Framework : StringTokenizer (Introduction) 

    Java : Collection Framework : StringTokenizer (Introduction) 

    Java : Collection Framework : StringTokenizer (Introduction) 


    Java : Collection Framework : StringTokenizer (Introduction) 

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Monday, 17 November 2014

    Java : Collection Framework : Deque (Contains method)


    Click here to watch in Youtube : https://www.youtube.com/watch?v=l3QDQAZ3zQE&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of contains(Object o) method.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(200);
            deque.add(300);
            deque.add(200);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Returns true if this deque contains the specified element.
             */
            boolean isExist = deque.contains(300);
            System.out.println("is 300 Exist :  " + isExist);
    
            isExist = deque.contains(10000);
            System.out.println("is 10000 Exist : " + isExist);
    
        }
    
    }
    
    
    
    
    
    
    
    
    Output
    deque : [200, 300, 200]
    
    is 300 Exist :  true
    is 10000 Exist : false

    To Download DequeDemoContains Project Click the below link
    https://sites.google.com/site/javaee4321/java-collections/DequeDemoContains.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (removeFirstOccurrence & removeLastOccurrence methods)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=3JIYOmAYVHY&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of removeFirstOccurrence(Object o) and removeLastOccurrence(Object o) methods.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(200);
            deque.add(300);
            deque.add(200);
            deque.add(5000);
            deque.add(200);
            deque.add(800);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Removes the first occurrence of the specified element from this
             * deque. If the deque does not contain the element, it is unchanged.
             */
            boolean isRemoved = deque.removeFirstOccurrence(200);
            System.out.println("isRemoved : " + isRemoved);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Removes the last occurrence of the specified element from this deque.
             * If the deque does not contain the element, it is unchanged.
             */
            isRemoved = deque.removeLastOccurrence(200);
            System.out.println("isRemoved : " + isRemoved);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    Output
    deque : [200, 300, 200, 5000, 200, 800]
    
    isRemoved : true
    deque : [300, 200, 5000, 200, 800]
    
    isRemoved : true
    deque : [300, 200, 5000, 800]
    

    To Download DequeDemoRemoveOcc Project Click the below link
    https://sites.google.com/site/javaee4321/java-collections/DequeDemoRemoveOcc.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Size method)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=h41jgoMwOPQ&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of size() method.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(2000);
            deque.add(5000);
            deque.add(10000);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Returns the number of elements in this deque.
             */
            int size = deque.size();
            System.out.println("size : " + size);
    
        }
    
    }
    
    
    
    
    
    
    Output
    deque : [2000, 5000, 10000]
    
    size : 3
    

    To Download DequeDemoSize Project Click the below link
    https://sites.google.com/site/javaee4321/java-collections/DequeDemoSize.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Remove Specific Element)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=bngctQC4JAA&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of remove(Object o) method.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(2000);
            deque.add(5000);
            deque.add(10000);       
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Removes the first occurrence of the specified element from this
             * deque. If the deque does not contain the element, it is unchanged.
             */
            boolean isRemoved = deque.remove(5000);
            System.out.println("isRemoved : " + isRemoved);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    Output
    deque : [2000, 5000, 10000]
    
    isRemoved : true
    deque : [2000, 10000]
    
    
    To Download DequeDemoRemoveElement Project Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoRemoveElement.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Remove & Poll Methods)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=7T1dBx-i98M&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of remove(),poll() methods.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(2000);
            deque.add(5000);
            deque.add(10000);
            deque.add(9000);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves and removes the head of the queue represented by this deque
             * (in other words, the first element of this deque). This method
             * differs from poll only in that it throws an exception if this deque
             * is empty.
             */
            Integer removedElement = deque.remove();
            System.out.println("removedElement : " + removedElement);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves and removes the head of the queue represented by this deque
             * (in other words, the first element of this deque), or returns null if
             * this deque is empty.
             */
            removedElement = deque.poll();
            System.out.println("removedElement : " + removedElement);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    
    
    Output
    deque : [2000, 5000, 10000, 9000]
    
    removedElement : 2000
    deque : [5000, 10000, 9000]
    
    removedElement : 5000
    deque : [10000, 9000]
    
    
    To Download DequeDemoRemovePoll Project Click the below link
    https://sites.google.com/site/javaee4321/java-collections/DequeDemoRemovePoll.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Sunday, 16 November 2014

    Java : Collection Framework : Deque (Push Method)


    Click here to watch in Youtube : 
    https://www.youtube.com/watch?v=7T1dBx-i98M&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of push(E e) method.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(2000);
            deque.add(5000);
            deque.add(10000);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Pushes an element onto the stack represented by this deque (in other
             * words, at the head of this deque)
             */
            deque.push(100);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    Output
    deque : [2000, 5000, 10000]
    
    deque : [100, 2000, 5000, 10000]
    
    
    
    
    
    
    
    
    
    
    
    


    To Download DequeDemoPush Project Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoPush.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Pop Method)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=CO8N4XhQWKI&list=UUhwKlOVR041tngjerWxVccw



    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of pop() method.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(2000);
            deque.add(5000);
            deque.add(10000);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Pops an element from the stack represented by this deque. In other
             * words, removes and returns the first element of this deque.
             */
            Integer value = deque.pop();
            System.out.println("pop : Value : " + value);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    Output
    deque : [2000, 5000, 10000]
    
    pop : Value : 2000
    deque : [5000, 10000]
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    


    To Download DequeDemoPop Project Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoPop.zip?attredirects=0&d=1



    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Element & Peek Methods)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=VrNmky2uRDE&list=UUhwKlOVR041tngjerWxVccw


    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of element() and peek() methods.
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(200);
            deque.add(300);
            deque.add(400);
            deque.add(500);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the head of the queue represented by
             * this deque (in other words, the first element of this deque). This
             * method differs from peek only in that it throws an exception if this
             * deque is empty.
             */
            Integer element = deque.element();
    
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the head of the queue represented by
             * this deque (in other words, the first element of this deque), or
             * returns null if this deque is empty.
             */
    
            element = deque.peek();
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
        }
    
    }
    
    
    
    
    
    
    
    
    Output
    deque : [200, 300, 400, 500]
    
    element : 200
    deque : [200, 300, 400, 500]
    
    element : 200
    deque : [200, 300, 400, 500]
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    To Download DequeDemoElementPeek Project Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoElementPeek.zip?attredirects=0&d=1


    See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Saturday, 15 November 2014

    Java : Collection Framework : Deque (DecendingIterator Method)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=av-fQK6fxeo&list=UUhwKlOVR041tngjerWxVccw


    DequeExample.java
    import java.util.Deque;
    import java.util.Iterator;
    import java.util.LinkedList;
    
    /*
     *  Example of descendingIterator() method
     */
    public class DequeExample
    {
    
        public static void main(String[] args)
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(100);
            deque.add(200);
            deque.add(300);
            deque.add(400);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Returns an iterator over the elements in this deque in reverse
             * sequential order. The elements will be returned in order from last
             * (tail) to first (head).
             */
    
            Iterator<Integer> iterator = deque.descendingIterator();
    
            System.out.println("Reverse Direction -- ");
    
            while (iterator.hasNext())
            {
                Integer value = iterator.next();
                System.out.println(value);
            }
    
        }
    
    }
    
    
    
    
    
    
    Output
    deque : [100, 200, 300, 400]
    
    Reverse Direction -- 
    400
    300
    200
    100
    
    
    
    
    
    To Download DequeDemodescendingIterator Project Click the below link
    https://sites.google.com/site/javaee4321/java-collections/DequeDemodescendingIterator.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Get & Peek Last Methods)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=GdITEdEoeDI&list=UUhwKlOVR041tngjerWxVccw


    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of getLast() and peekLast() methods.
     */
    public class DequeExample
    {
    
        public static void main( String[] args )
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(100);
            deque.add(200);
            deque.add(300);
            deque.add(400);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the last element of this deque. This
             * method differs from peekLast only in that it throws an exception if
             * this deque is empty.
             */
            Integer element = deque.getLast();
    
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the last element of this deque, or
             * returns null if this deque is empty.
             */
            element = deque.peekLast();
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
        }
    }
    
    
    
    
    
    
    Output
    deque : [100, 200, 300, 400]
    
    element : 400
    deque : [100, 200, 300, 400]
    
    element : 400
    deque : [100, 200, 300, 400]
    
    
    
    
    
    
    
    
    
    To Download DequeDemoGetPeekLast Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoGetPeekLast.zip?attredirects=0&d=1

    See also:


  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java : Collection Framework : Deque (Get & Peek First Methods)

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of getFirst() and peekFirst() methods.
     */
    public class DequeExample
    {
    
        public static void main( String[] args )
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(100);
            deque.add(200);
            deque.add(300);
            deque.add(400);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the first element of this deque. This
             * method differs from peekFirst only in that it throws an exception if
             * this deque is empty.
             */
            Integer element = deque.getFirst();
    
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves, but does not remove, the first element of this deque, or
             * returns null if this deque is empty.
             */
            element = deque.peekFirst();
            System.out.println("element : " + element);
            System.out.println("deque : " + deque + "\n");
    
        }
    }
    
    
    
    
    Output
    deque : [100, 200, 300, 400]
    
    element : 100
    deque : [100, 200, 300, 400]
    
    element : 100
    deque : [100, 200, 300, 400]
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    To Download DequeDemoGetPeekFirst Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoGetPeekFirst.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Thursday, 13 November 2014

    Java : Collection Framework : Deque (Remove & Poll Last Methods)


    Click here to watch in Youtube :
    https://www.youtube.com/watch?v=ELIqGs6U-0s&list=UUhwKlOVR041tngjerWxVccw

    DequeExample.java
    import java.util.Deque;
    import java.util.LinkedList;
    
    /*
     *  Example of removeLast() and pollLast() methods.
     */
    public class DequeExample
    {
    
        public static void main( String[] args )
        {
            Deque<Integer> deque = new LinkedList<Integer>();
            deque.add(100);
            deque.add(200);
            deque.add(300);
            deque.add(400);
    
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves and removes the last element of this deque. This method
             * differs from pollLast only in that it throws an exception if this
             * deque is empty.
             */
            Integer removedElement = deque.removeLast();
    
            System.out.println("removedElement : " + removedElement);
            System.out.println("deque : " + deque + "\n");
    
            /*
             * Retrieves and removes the last element of this deque, or returns null
             * if this deque is empty.
             */
            removedElement = deque.pollLast();
            System.out.println("removedElement : " + removedElement);
            System.out.println("deque : " + deque + "\n");
    
        }
    }
    
    
    
    
    
    
    Output
    deque : [100, 200, 300, 400]
    
    removedElement : 400
    deque : [100, 200, 300]
    
    removedElement : 300
    deque : [100, 200]
    
    
    
    
    
    
    
    
    
    To Download DequeDemoRemovePollLast Project Click the below link

    https://sites.google.com/site/javaee4321/java-collections/DequeDemoRemovePollLast.zip?attredirects=0&d=1

    See also:

  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial