View RSS Feed

Recent Blogs Posts

  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. ...
  2. Adding Elements to a List

    by , 02-19-2012 at 06:47 AM
    Elements are added to list by using these 4 different methods given below:
    Java Code:
    MyList.add("1");
    //or
    MyList.add(varName);
    An item is added by it to end of list.
    At a particular location, elements could be added as given below.
    Java Code:
    MyList.add(0, "2");
    //or
    MyList.add(0, varName);
    Zero tells the element location, as given in above code. This is basically added as 1st element.
    Other two ...
    Categories
    Linked List