About NullPointer Exception in Arraylist

Posted by user2234456 on Stack Overflow See other posts from Stack Overflow or by user2234456
Published on 2013-06-25T09:42:36Z Indexed on 2013/06/25 10:21 UTC
Read the original article Hit count: 129

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!

© Stack Overflow or respective owner

Related posts about java

Related posts about swing