package cys; public class Example9_2 { public static void main(String[] args) { // TODO Auto-generated method stub People personal1,personal2; StringBuffer str=new StringBuffer(); personal1 = new People("李四",str); personal2 = new People("王五…
通常,我们在代码中创建一个集合(例如,List 或 Set ),并直接用一些元素填充它. 实例化集合,几个 add方法调用,使得代码重复. public class Demo01 { public static void main(String[] args) { List<String> list = new ArrayList<>(); list.add("abc"); list.add("def"); list.add("gh…