java - Array List overflow -


my array list contains integers values less 100 want keep information of index attached value hence added 1000 times index value value of element , have been retrieving indexes using arr<>(i)/1000 while original value arr<>(i)%1000. getting

exception in thread "main" java.lang.indexoutofboundsexception: index: 2, size: 0  

exception following code:

static long buymaximumproducts(long n, long n, arraylist<long> a) {      long temp=0;     long maxresult=0;     if(a.isempty())         return n;     (long cell:a) {         (int = 1; <= cell/1000; i++) {             if(n-i*(cell%1000)>0){                 a.remove(cell);                 temp = buymaximumproducts(n-i*(cell%1000),n+i,a);                 if(temp > maxresult)                     maxresult = temp;                 a.add((int) ((cell/1000)-1), cell);             }             else                 maxresult=n+i-1;         }      }     return maxresult; }  


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -