jieba分詞歸納總結
阿新 • • 發佈:2021-11-09
package com.bo.collection;
import java.util.ArrayList;
import java.util.Iterator;
public class Demo08 {
public static void main(String[] args) {
ArrayList<String> arrayList=new ArrayList();//如果不使用泛型 Integer型別轉String回報錯
arrayList.add("張三"); //使用泛型 別的型別資料就新增不進去 不用擔心轉換出錯
arrayList.add("李四");
//arrayList.add(100);
//arrayList.add(200);
for (String string:arrayList) {
System.out.println(string);
}
ArrayList<Student> arrayList1 =new ArrayList();
Student s1 = new Student("趙",20);
Student s2 = new Student("錢",21);
Student s3 = new Student("孫",22);
arrayList1.add(s1);
arrayList1.add(s2);
arrayList1.add(s3);
Iterator<Student> it =arrayList1.iterator();//不寫泛型就是Object型別
while(it.hasNext()){
Student s = it.next();
System.out.println(s.toString());
}
}
}