framework

framework - import java.util.*; public class framework cfw_...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.util.*; public class framework { public static void main(String args[]) { /** * list practice ** */ List<String> origList = new ArrayList<String>(); origList.add("Chi"); origList.add("Eric"); origList.add("Xin"); origList.add("Paul"); /** * Question 0: what are the differences between the following * declarations? Answer: for the following declarations, the left hand * side are interfaces and the right hand side are implementations. * Since ArrayList and LinkedList are the implementations of List, * therefore the second and the third declarations are legal. * Conversely, the first and the last two declarations are illegal. * * * Which are legal and which are illegal? List<String> origList = new * List<String>() illegal List<String> origList = new * ArrayList<String>() legal List<String> origList = new * LinkedList<String>() legal ArrayList<String> origList = new * ArrayList<String>() illegal ArrayList<String> origList = new * LinkedList<String>() illegal */ /** * Question 1 - Display the names on the list * Using indexing to access * the individual names. Using an iterator. for-each * */ for (int index = 0; index < origList.size(); index++) System.out.println(origList.get(index) + " ");
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

framework - import java.util.*; public class framework cfw_...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online