java_util_test(轉)
java_util_test(轉)[@more@]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();
}
}
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();
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10617731/viewspace-958155/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- IsPostBack深入探討(轉轉轉轉轉)
- 玩轉SSH埠轉發
- 彼得反轉原理(轉載)
- java 跳轉語句(轉)Java
- JDom 常用轉換方法 (轉)
- 行列轉換 交叉表 (轉)
- Excel轉PDF怎麼轉?Excel轉PDF方法有哪些Excel
- 語音轉文字工具,語音轉文字怎樣轉?
- 什麼是SSH埠轉發(本地轉發、遠端轉發、動態轉發)?
- SQL 行轉列,列轉行SQL
- (轉)OC專案轉Swift指南Swift
- pdf轉word如何線上轉換?
- 轉轉OLAP自助分析實踐
- JS轉換HTML轉義符JSHTML
- (轉)SqlServer裡DateTime轉字串SQLServer字串
- Mysql - 行轉列、列轉行MySql
- js跳轉頁面方法(轉)JS
- oracle行列轉換-行轉列Oracle
- oracle行列轉換-列轉行Oracle
- 內碼轉換技術 (轉)
- 金額大寫轉換(轉)
- | / - 的旋轉效果實現(轉)
- 【轉】ckEditor使用方法 轉帖
- 從C轉入C++ (轉)C++
- svg 至 flash的轉化 (轉)SVG
- 玩轉Windows桌面圖示 (轉)Windows
- 大寫金額轉換 (轉)
- 用Javascript轉換原始碼 (轉)JavaScript原始碼
- 玩轉網頁捲軸(轉)網頁
- 熊與猴的轉換(轉)
- 轉入OO思維模式 (轉)模式
- ppt轉pdf怎麼轉?試試這個轉換技巧!
- heic格式轉換jpg工具——轉易俠heic轉換器
- java型別轉換與強制型別轉換(轉)Java型別
- PDF轉PPT怎麼轉?好用的PDF轉換方法有哪些?
- 如何將圖片轉word?圖文轉換選轉易俠
- heic格式轉換jpg免費怎麼轉?轉易俠可以
- Oracle實驗(02):轉換 & 轉譯Oracle