import com.dianping.lion.shade.org.apache.curator.shaded.com.google.common.collect.Lists; import io.swagger.models.auth.In; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; public class Test02 { public static void main(String[] args) { ArrayList<Integer> integers = new ArrayList<>(); integers.add(1); integers.add(2); integers.add(3); integers.add(4); List<List<Integer>> orderNoListList = Lists.partition(integers, 2); System.out.printf(orderNoListList.toString()); List<Integer> listNew= Lists.reverse(integers); System.out.printf(listNew.toString()); System.out.println("---"); ArrayList<Integer> integers1 = new ArrayList<>(); integers1.add(1); integers1.add(2); integers1.add(3); int arrayListCapacity = getArrayListCapacity(integers1); System.out.println(arrayListCapacity+""); ArrayList<Object> objects = Lists.newArrayListWithCapacity(2); int arrayListCapacity1 = getArrayListCapacity(objects); System.out.println(arrayListCapacity1+""); } public static int getArrayListCapacity(ArrayList<?> arrayList) { Class<ArrayList> arrayListClass = ArrayList.class; try { Field field = arrayListClass.getDeclaredField("elementData"); field.setAccessible(true); Object[] objects = (Object[])field.get(arrayList); return objects.length; } catch (NoSuchFieldException e) { e.printStackTrace(); return -1; } catch (IllegalAccessException e) { e.printStackTrace(); return -1; } } }
import com.dianping.lion.shade.org.apache.curator.shaded.com.google.common.collect.ImmutableList; import com.dianping.lion.shade.org.apache.curator.shaded.com.google.common.collect.Lists; public class Test03 { public static void main(String[] args) { String str="3r34dsfsd"; ImmutableList<Character> characters = Lists.charactersOf(str); System.out.println(characters); } }