About NullPointer Exception in Arraylist
- by user2234456
List<PrcSubList> listSl = new ArrayList<PrcSubList>();
if (listSl == null || listSl.size() == 0) {
PrcSubList subListAdd=coreService.addSubListByAddAlert(childSub);
System.out.println("sublist after insert db :" + subListAdd.getName());
listSl.add(subListAdd);
System.out.println(listSl.size() +" sublist after insert list:" + listSl.get(0).getName());
}
Ouput with first System.out.println("sublist after insert db :" + subListAdd.getName());
sublist after insert db :SYSTEM_ALERT_12312313
Problem
But i have NullPointerException with 2nd
System.out.println(listSl.size() +" sublist after insert list:" + listSl.get(0).getName());
Can you help me!