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

Popular posts from this blog

dns - How To Use Custom Nameserver On Free Cloudflare? -

python - Pygame screen.blit not working -

c# - Web API response xml language -