The answer from a library (DBpediaLookupClient.variableBindings()
) results in
List<Map<String, String>>
I am trying to check is if the list if empty or not. What I have tried so far is
if (dbpedialookup.variableBindings() != null && !dbpedialookup.variableBindings().isEmpty()) {
System.out.println("Results Present);
} else {
System.out.println("No Results");
}
But, on items where the resultant List is []. Its throwing,
Exception in thread "main" java.lang.NullPointerException
How do we check for null
in such a situation?