checking array length in java and if array length is 0 then throw custom exception -
i getting list while retrieveing converting array , sending later caller function shown below
rokeritemlist = brokerinvoice.getlineitems(); return rokeritemlist.toarray(new brokerinvoicelineitem[rokeritemlist.size()]);
now query can happens list retrieved may not contain elements , want put check while converting array before check converted array length , if 0 throw custom exception shown below please advise how implement check
throw new aseruntimeexception( " no items there in array ");
try like:
if (rokeritemlist.isempty()) {//check if list empty //throw exception } //your conversion logic
Comments
Post a Comment