if the whole code is needed let me know.

System.out.print("Unsafe banks are : "); while(true) { int minId=-1; double min=1000000000.0; for(int i=0; i<n; i++) { if(safe[i]==true && assets[i]<min && assets[i]<limit) { min = assets[i]; minId = i; } } if(minId==1) break; safe[minId] = false; System.out.print(minId+" "); for(int i=0; i<n; i++) { if(given[i][minId]>0) { assets[i]-=given[i][minId]; given[i][minId]=0; } } } } }