class="java">
package zy.page.demo.test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import zy.page.demo.model.Excelmodel;
public class SubStringTest {
public static void main(String[] args) {
String str = "2322qq.com,jack,2322qq.com,jack,87434@qq.com,zy,87434@qq.com,zy,87434@qq.com,zy";
String[] arr = str.split(",");
Excelmodel eml =new Excelmodel() ;
ArrayList<Excelmodel> al = new ArrayList<Excelmodel>();
for (int i = 0; i < arr.length - 1; i++) {
eml.setEmail(arr[i]);
int j = i + 1;
eml.setName(arr[j]);
String email=eml.getEmail();
String name=eml.getName();
Excelmodel em=new Excelmodel(email,name);
System.out.println("email" + em.getEmail());
System.out.println("name" + em.getName());
i = i + 1;
al.add(em);
}
for(int i=0;i<al.size();i++){
System.out.println(al.get(i).getEmail()+al.size()+al.get(i).getName());
}
//数组转化为list
List<String> list = Arrays.asList(arr);
for (int i = 0; i < list.size(); i++) {
System.out.println(list.get(i));
}
}
}
- 大小: 34.3 KB