Update the values of array
int index = 0 ; for ( Map . Entry entry : m . entrySet ( ) ) { ArrayList < Integer > al = m . get ( entry . getKey ( ) ) ; for ( int i = 0 ; i < al . size ( ) ; i ++ ) arr [ index ++ ] = al . get ( i ) ; } }