package com.ram;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Stack;
import java.util.Vector;
/**
*
* @author ramakrishna.v
*
*/
public class ListInterfaceExamples {
public static void main(String[] args) {
List<String> arayList = new ArrayList<String>();
arayList.add("R");
arayList.add("A");
arayList.add("M");
retrieveValues("List","ArrayList",arayList);
List<String> linkedList = new LinkedList<String>();
linkedList.add("R");
linkedList.add("A");
linkedList.add("M");
retrieveValues("List","LinkedList",linkedList);
List<String> stack = new Stack<String>();
stack.add("R");
stack.add("A");
stack.add("M");
retrieveValues("List","Stack",stack);
List<String> vector = new Vector<String>();
vector.add("R");
vector.add("A");
vector.add("M");
retrieveValues("List","Vector",vector);
}
@SuppressWarnings({ "rawtypes"})
static void retrieveValues(String var1,String var2,Collection collection) {
System.out.println(var1+" interface using "+var2+" class");
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
String string = (String) iterator.next();
System.out.println(string);
}
System.out.println("===========================");
}
}
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Stack;
import java.util.Vector;
/**
*
* @author ramakrishna.v
*
*/
public class ListInterfaceExamples {
public static void main(String[] args) {
List<String> arayList = new ArrayList<String>();
arayList.add("R");
arayList.add("A");
arayList.add("M");
retrieveValues("List","ArrayList",arayList);
List<String> linkedList = new LinkedList<String>();
linkedList.add("R");
linkedList.add("A");
linkedList.add("M");
retrieveValues("List","LinkedList",linkedList);
List<String> stack = new Stack<String>();
stack.add("R");
stack.add("A");
stack.add("M");
retrieveValues("List","Stack",stack);
List<String> vector = new Vector<String>();
vector.add("R");
vector.add("A");
vector.add("M");
retrieveValues("List","Vector",vector);
}
@SuppressWarnings({ "rawtypes"})
static void retrieveValues(String var1,String var2,Collection collection) {
System.out.println(var1+" interface using "+var2+" class");
Iterator iterator = collection.iterator();
while (iterator.hasNext()) {
String string = (String) iterator.next();
System.out.println(string);
}
System.out.println("===========================");
}
}
No comments:
Post a Comment