java_util_test

猎鹰金雕医药

猎鹰金雕医药

2016-02-19 17:04

下面这个java_util_test教程由图老师小编精心推荐选出,过程简单易学超容易上手,喜欢就要赶紧get起来哦!

  

package com.diegoyun.apiLearning;
import java.util.*;
/**
* User: diegoyun
* Date: 2005-1-30
* Time: 19:03:29
*/
public final class UtilTutorial
{
public static void collectionRetainTest()
{
System.out.println("**********collectionRetainTest begin:");
Collection c1 = new ArrayList();
Collection c2 = new ArrayList();
c1.add("aaa");
c1.add("bbb");
c1.add("ccc");
c2.add("ddd");
c2.add("ccc");
c2.add("eee");
boolean isRetainSucceed = false;
isRetainSucceed = c2.retainAll(c1);
System.out.println("isRetainSucceed = " + isRetainSucceed);
System.out.println("********** Print collection c2 values ");
for (Iterator iter = c2.iterator(); iter.hasNext();)
{
String s = (String) iter.next();
System.out.println("element = " + s);
}
System.out.println("**********collectionRetainTest end:");
}
public static void listIteratorTest(){
System.out.println("**********listIteratorTest begin:");
List list = new ArrayList();
list.add("aaa");
list.add("bbb");
list.add("ccc");
ListIterator iter = list.listIterator();
System.out.println("**************** Iterating List forward :");
while(iter.hasNext()){
String s = (String)iter.next();
System.out.println("**********element = " + s);
}
System.out.println("**************** Iterating List backward :");
while(iter.hasPrevious()){
String s = (String)iter.previous();
System.out.println("**********element = " + s);
}
System.out.println("**************** Add element into List :");
while(iter.hasNext()){
int i = iter.nextIndex();
if (i==2)
iter.add("ddd");
String s = (String)iter.next();
System.out.println("**********element = " + s);
}
System.out.println("**************** Iterating List backward after add element:");
while(iter.hasPrevious()){
String s = (String)iter.previous();
System.out.println("**********element = " + s);
}
System.out.println("**********listIteratorTest end:");
}
public static void main(String[]args){
// UtilTutorial.collectionRetainTest();
UtilTutorial.listIteratorTest();
}
}

(本文来源于图老师网站,更多请访问http://m.tulaoshi.com/bianchengyuyan/)
展开更多 50%)
分享

猜你喜欢

java_util_test

编程语言 网络编程
java_util_test

Test of the Java Skill(1)

编程语言 网络编程
Test of the Java Skill(1)

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

Java_util_package

编程语言 网络编程
Java_util_package

Test of the Java Skill(2)

编程语言 网络编程
Test of the Java Skill(2)

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

Test of the Java Skill(4)

编程语言 网络编程
Test of the Java Skill(4)

重用java.util.Observable类

编程语言 网络编程
重用java.util.Observable类

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

Linux下的多线程编程

Linux下的多线程编程

excel计算年龄准确到几岁几月几天

excel计算年龄准确到几岁几月几天
下拉加载更多内容 ↓