Tuesday, February 20, 2007

ArrayList size check

Doing a check on list size and if it has data then create an exception.

errorList = (ArrayList) this.validateProfile();
if(null != errorList && !errorList.isEmpty()){
additionalInfo[0] = errorList;
throw ExceptionFactory.createException(

if(null != errorList && 0 < errorList.size())

It can be done in this way as well, but

0 < errorList.size()

This is a 2 step process where we are getting the size and then checking whether it is greater than 0.

0 Comments:

Post a Comment

<< Home