Coders Packet

Finding index of nth occurrence of an element in an array using Java

By J Satya Srinivas

This project is developed using Java and it can be used to find out the index of nth occurrence of an element in an array.

This project is developed using Java and it will be very useful to find out the index of nth occurrence of an element in an array. For example, if the user would like to find out the index of 4th occurrence of the element '4', the user can find it out using this project. On running the project, the user will be asked to enter the element to be searched for. Then the user will be asked to enter which occurrence of that particular element the user would like to find. Then the output will display the index of nth occurrence of the element in the array if that element occurred n times in that array.

In the example that we considered, if the element '4' occurred at least 4 times in the given array, the output will display the index of 4th occurrence of the element '4' in the given array. If the element '4' didn't occur 4 times in the given array, then the output will display that the element '4' did not occur 4 times and it will also display the number of times the element '4' occurred. If the element 4 did not occur in the array at all, the output will display that the element '4' did not occur in the array at all.

Screenshots:

Example 1

 

Example 2

 

Example 3

Download project

Reviews Report

Submitted by J Satya Srinivas (satyasrinivasj)

Download packets of source code on Coders Packet