Java examples for Language Basics:for
Retrieving Items from a LinkedList with enhanced for loop
import java.util.LinkedList; public class Main { public static void main(String[] args) { LinkedList<String> officers = new LinkedList<String>(); officers.add("Blake"); officers.add("Bates"); officers.add("Jack"); officers.add("Tom"); officers.add("Lady"); officers.add(2, "new"); for (String s : officers) System.out.println(s);//from w ww. j ava 2s . c o m } }