码迷,mamicode.com
首页 > 其他好文 > 详细

一些可能有用的代码

时间:2015-07-18 22:31:02      阅读:199      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!