Loop to iterate over the map
for ( Map . Entry < Integer , Integer > i : m . entrySet ( ) ) { if ( last != - 1 && i . getValue ( ) != last ) { return false ; } else { last = i . getValue ( ) ; } } return true ; }