public static void main(String[] args) { List<DemoClass> demos = null; for (DemoClass demo : demos) { System.out.println("123"); } }
list.size()>0就行
public static void main(String[] args) {
DemoClass dc=null;
List<DemoClass> demos = new ArrayList();
demos.add(dc);
System.out.println(demos.size());
for (DemoClass demo : demos) {
System.out.println("123");
}
}