1.List中的toArray(将list转换成数组存放)
T[ ]testArray = list.toArray(new T[list.size]])
Integer[] array = list.toArray(new Integer[list.size()]); 示例:public class Test { public static void main(String[] args) { List<Integer> list = new ArrayList<Integer>(); list.add(1); list.add(2); Integer[] array = list.toArray(new Integer[list.size()]); for(int element:array){ System.out.println(element); } } }2.String.lastIndexOf(b)表示b字符串在a字符串中最后出现的位置。如
String a="abcdabcd";
int x = a.lastIndexOf(b)
结果:x=7