check list for empty and null java
/*
If you use the Apache Commons Collections library in your project,
you may use
*/
CollectionUtils.isEmpty(MyList) or MapUtils.isEmpty(MyList)
/*
which respectively check
if a collection or a map is empty or null
(i.e. they are "null-safe").
*/
/*
Small tip:
remember that the less code you write,
the less code you need to test as the complexity of your code decreases.
*/