黑马程序员技术交流社区

标题: 在Interger泛型的list集合中存储String类型 [打印本页]

作者: world.net    时间: 2015-6-17 23:19
标题: 在Interger泛型的list集合中存储String类型
  1. public class insertStrToArray {
  2.         public static void main(String[] args) throws Exception {
  3.                 ArrayList<Integer> list = new ArrayList<Integer>();
  4.                 Method methodAddString = list.getClass().getMethod("add", Object.class);
  5.                 methodAddString.invoke(list, "abc");
  6.                 System.out.println(list);
复制代码





欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2