首页 > 其他 > 详细

一些可能有用的代码

时间:2015-07-18 22:29:01      阅读:206      评论:0      收藏:0      [点我收藏+]

动态代理

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); // 这种要快点

一些可能有用的代码

原文:http://www.cnblogs.com/sycamore/p/4657687.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!