Results 1 to 6 of 6
- 05-13-2011, 12:16 PM #1
Member
- Join Date
- Mar 2011
- Posts
- 20
- Rep Power
- 0
obtaining the most highly repeated entry in an arraylist
i have written a program which accepts a file from user and data is stored in an ArrayList named "employee". i need to find out the name which is repeated the most number of times. how do i get the most highly repeated name in the arraylist???
- 05-13-2011, 12:43 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Build a wall around Donald Trump; I'll pay for it.
- 05-16-2011, 10:31 AM #3
ankit1801, your duplicate post of the question has been locked. Please continue the discussion here.
db
- 05-16-2011, 12:41 PM #4
Member
- Join Date
- Mar 2011
- Posts
- 20
- Rep Power
- 0
Sorry was not able to locate my older thread.
i have not worked with maps. could you give me a short example or some kind of pseudocode so that i can understand how to implement it in my program?
- 05-16-2011, 12:49 PM #5
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 14,422
- Blog Entries
- 7
- Rep Power
- 29
Put your names in the Map<String, Integer> like this:
Java Code:private Map<String, Integer> map= new HashMap<String, Integer>(); public void add(String key); Integer freq= map.get(key); if (freq == null) freq= Integer.valueOf(0); map.put(key, freq+1); }
JosBuild a wall around Donald Trump; I'll pay for it.
- 05-16-2011, 02:44 PM #6
Similar Threads
-
removing repeated entries in arraylist
By ankit1801 in forum New To JavaReplies: 1Last Post: 04-15-2011, 07:34 AM -
Obtaining straightline pixels
By base2coder in forum New To JavaReplies: 2Last Post: 09-10-2009, 02:26 AM -
Obtaining relative path outside of executable JAR
By tjsaker in forum Advanced JavaReplies: 1Last Post: 11-14-2008, 07:48 AM -
increase stack size in eclipse for highly recursive method.
By Daedalus in forum EclipseReplies: 3Last Post: 09-27-2008, 05:46 AM -
socket Multithreading - & - Obtaining the IP of a client!
By bluebarca in forum NetworkingReplies: 1Last Post: 11-16-2007, 11:09 AM
Bookmarks