Here is another example written in Java: import java . util . * ; public class Main { static void printEvenOccurences ( int arr [ ] ) { HashMap < Integer , Integer > countMap = new HashMap < Integer , Integer > ( ) ; // counting occurrences of array elements for ( int i = 0 ; i < arr . length ; i ++ ) { if ( countMap . get ( arr [ i ] ) == null ) { countMap . put ( arr [ i ] , 1 ) ; } else { countMap . put ( arr [ i ] , countMap . get ( arr [ i ] ) + 1 ) ; } } // print numbers with even occurrences for ( Map . Entry < Integer , Integer > entry : countMap . entrySet ( ) ) { if ( entry . getValue ( ) % 2 == 0 ) { System . out . println ( entry . getKey ( ) ) ; } } } public static void main ( String [ ] args ) { int arr [ ] = { 4 , 2 , 4 , 5 , 2 , 3 , 1 , 6 , 6 } ; printEvenOccurences ( arr ) ; } } In this illustration, the printEvenOccurences method establishes a HashMap to track the frequency of each number, and subsequently outputs the numbers that occur an even number of times.