Array implementation

I have to implement the following logic in java....

suppose there are N elements in an array....

- If elements are repeated more than once then return the element that is repeated the most number of times...

ex: 2,2,1,3,1,2 - this should return 2.

- If elements are repeated equally then return the first element in the array....

ex: 2,2,1,1,3,3 - this should return 2 (first element).

Any help in this implementation is appreciated...thanks...

[489 byte] By [Naik1983a] at [2007-11-26 18:37:26]
# 1
http://java.sun.com/docs/books/tutorial/index.htmlHave fun learning. Don't just plop your homework assignment down for us to do for you (which is what your post amounts to with no specific java-related question there).
warnerjaa at 2007-7-9 6:11:30 > top of Java-index,Java Essentials,Java Programming...
# 2
i dint ask you to write the code for me....just wanted few ideas as to how to go abt it...
Naik1983a at 2007-7-9 6:11:30 > top of Java-index,Java Essentials,Java Programming...
# 3
well the tutorial is a good place to start then.
kikemellya at 2007-7-9 6:11:30 > top of Java-index,Java Essentials,Java Programming...
# 4
warnerja you're such a meanie ;-)More specifically, look at [url= http://java.sun.com/docs/books/tutorial/java/nutsandbolts/arrays.html]Arrays[/url]
Djaunla at 2007-7-9 6:11:30 > top of Java-index,Java Essentials,Java Programming...
# 5

I wrote the code which can find the element that is repeated most number of times in the array of elements....

But how do i determine if the elements are repeated more than once or just repeated equally as shown in the examples in the above post ....i need to get this logic embedded in my prj very soon and i am not able to think of the perfect logic to implement this....Any comments/suggenstions?

Thanks....

Naik1983a at 2007-7-9 6:11:30 > top of Java-index,Java Essentials,Java Programming...