I get a null pointer exception for this statement.
accountList.getTrxnList().getTrxns().size() > 0
accountList is a list of accounts I get from an external API call. And I am sure that a non-null accountList value is returned.But I am not confident about getTrxns() has any values. So before processing I check whether there are any Trxns but this also results in a null pointer exception.
This is my model class
public class AccountList{
private TrxnList trxnList;
public static class TrxnList {
private List<Trxn> trxns;
public List<Trxn> getTrxns() {
return trxns;
}
}
}
Can someone please point out why this is raising nullpointer exception? I did some research on this so I cannot understand this raising nullpointer exception even if there are no items in trxns List.
Thank you.