Click here to Skip to main content
15,868,142 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The addWord method is a method where the parameter represents a case-sensitive word that has been found in a document. The count of occurrences for any word must start at 0 and be increased by 1 on each call with it as a parameter to this method.

What I have tried:

I am unsure how to achieve this and this is what the method looks like,

Java
public void add (String word)
{
}
Posted
Updated 15-Jan-23 3:15am

1 solution

The obvious choice would be to store the words in a collection of some sort. Maybe the Map (Java Platform SE 8 )[^] would be a good one.
 
Share this answer
 
Comments
0x01AA 15-Jan-23 10:30am    
Map I think is really a good one. 5
Richard MacCutchan 15-Jan-23 12:00pm    
Thank you. I wonder sometimes whether these students get any actual teaching?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900