一些可能有用的代码

动态代理

Interface proxy = (Interface)Proxy.newProxyInstance(
  Interface.class.getClassLoader(),
  new Class[] { Interface.class },
  new DynamicProxyHandler(real)); // DynamicProxyHandler要实现InvocationHandler接口

声明一个数组和打印一个数组

String[] aArray = new String[5];
String[] bArray = { "a", "b", "c", "d", "e"};
String[] cArray = new String[]{ "a", "b", "c", "d", "e" };
System.out.println(Arrays.toString(cArray));

从数组创建ArrayList

String[] aArray = { "a", "b", "c" };
List<String> aList = new ArrayList<>(Arrays.asList(aArray)); // 这种方式要慢一点
List<String> bList = new ArrayList<>();
Collections.addAll(bList, aArray); // 这种要快点
posted @ 2015-07-18 21:08  sycamore tree  阅读(201)  评论(0编辑  收藏  举报