View RSS Feed

Algorithm and Data Structure

Algorithm and data structure examples in Java.

  1. Adding and Accessing Queue Elements

    by , 02-19-2012 at 07:05 AM
    Call add() method for addition of the elements to Queue. This is an inherited type of method of Collection interface.

    Different elements are added to a Queue which is explained by this given code.

    Java Code: This is the code to explain add operation in Java Queue
    Queue myQueue = new LinkedList();
    myQueue.add("element 1");
    myQueue.add("element 2");
    myQueue.add("element 3");
    In a Queue, added elements get stored in internal order and they are dependent upon implementation. ...