Can You please help me in this:
I need to count the number of each value in non fixed array
for example
3 times the word 'java' exist
4 times the word 'programming' exists and etc
Many Thanks
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Can You please help me in this:
I need to count the number of each value in non fixed array
for example
3 times the word 'java' exist
4 times the word 'programming' exists and etc
Many Thanks
Use a map from string keys to integer count values. For each item in the array
(1) If no entry exists in the map for that item, create one with a value of 1
(2) If an entry does exist increment its value.
The Map Interface (The Java™ Tutorials > Collections > Interfaces)
5 minutes of programming and I get this result:
*** code removed ***
Last edited by Norm; January 4th, 2013 at 01:57 PM. Reason: spoonfed code removed.
@icool - Instead of spoonfeeding code to the OP, how about helping him learn how to program so he can write his own code.
http://www.javaprogrammingforums.com...n-feeding.html
If you don't understand my answer, don't ignore it, ask a question.
Ok, I see what you mean