// 来 自 n o w j a v a . c o m
import java.util.LinkedList;
public class Main {
public static void main(String[] args) {
LinkedList lList = new LinkedList();
lList.add("1");
lList.add("2");
lList.add("3");
lList.add("4");
lList.add("5");
lList.add("2");//来自 N o w J a v a . c o m - 时 代 Java
int index = lList.indexOf("2");
if(index != -1){
System.out.println("First occurrence of 2 in LinkedList is at index : " + index);
} else {
System.out.println("LinkedList does not contain 2");
}
index = lList.lastIndexOf("2");
if(index != -1) {
/**代码未完, 请加载全部代码(NowJava.com).**/
本文系作者在时代Java发表,未经许可,不得转载。如有侵权,请联系nowjava@qq.com删除。