Driver code
public static void main ( String args [ ] ) { int arr [ ] = { 1 , 2 , 2 , 2 , 2 , 3 , 4 , 7 , 8 , 8 } ; int n = arr . length ; int x = 2 ; System . out . println ( countOccurrences ( arr , n , x ) ) ; } }