Stroring the max candy + 1
int mxcandy = candy [ 0 ] ; for ( int i = 0 ; i < candy . length ; i ++ ) { if ( mxcandy < candy [ i ] ) { mxcandy = candy [ i ] ; } } int fr1 [ ] = new int [ mxage + 1 ] ; Arrays . fill ( fr1 , 0 ) ; int fr2 [ ] = new int [ mxcandy + 1 ] ; Arrays . fill ( fr2 , 0 ) ;