View RSS Feed

Algorithm and Data Structure

Algorithm and data structure examples in Java.

  1. Accessing Items from a List

    by , 02-19-2012 at 07:50 AM
    Get List Size:

    To get the List size, method “size()”is used. Size of MyList will be printed by this code.
    Java Code:
    Get Item:

    For getting a specific spot value, use get() method. In this method index of the List is provided. In case when index is not present, IndexOutOfBoundsException gets thrown.

    Element is not removed from the list by this method. Just this object is returned. This given code will ...