Friday, 17 October 2014

Java : Collection Framework : LinkedList (Get each element using for-each loop)



Click here to watch in Youtube : https://www.youtube.com/watch?v=-UQw_YRP72c

LinkedListForEachExample.java
import java.util.LinkedList;

public class LinkedListForEachExample
{

    public static void main( String[] args )
    {
        LinkedList<Integer> linkedList = new LinkedList<Integer>();

        linkedList.add(100);
        linkedList.add(200);
        linkedList.add(300);
        linkedList.add(400);

        /*
         * Using for-each loop getting each element from the linkedList.
         */

        for( Integer value : linkedList )
        {
            System.out.println(value);
        }

    }

}

Output
100
200
300
400

To Download LinkedListDemoForeach Project Click the below link

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

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge