Question: Im given a task which i am a little confused to understand. Here is the question statement:

---

The following program should read a file and store all its tokens in a member variable.
Your task is to write a single method that returns the number of items in tokenMap, the average length (as double value) of the elements in tokenMap, and the number of tokens starting with character "a".

---

Here the tokenMap is an object of type `HashMap<String, Integer>`;

I do have some idea about HashMap but what i want to know the "key value" for HashMap required is a single character or the whole word?? that i should store in tokenMap.

Also how can i compute the average length?

Answer: 
Reading the question closely, it seems that you have to read a file, extract each word and use it as the key value, and store the length of each key as the integer: 

```
an example line

```

leads to a HashMap like this

```
an : 2
example : 7
line : 4

```

After you've built your map (made of keys mapping to entries, or seemingly elements in the question), you'll need to run some statistics over it to find 

1. the number of keys (look at HashMap)
2. the average length of all keys (again, simple enough)
3. the number beginning with "a" (just look at the String)

Then make a value object containing these values and return it from the method that does the statistics. 

I know I've given more information that you require, but someone else may benefit from a little extra help.
> 
> should i split it based upon words or
>  based upon each character
> 
> 
> 

The requirement is to make tokens, so you should split them based on words. Each word becomes a unique String key. It would make sense for the value to be the count of each token.

If the file you are reading has these three lines:

```
int alpha;
int beta;
float delta;

```

Then you should have something like 

```
<"int", 2>
<";", 3>
<"alpha", 1>
<"beta", 1>
<"float", 1>
<"delta", 1>

```

(The semicolon may or may not be considered a token.) 
Your average length would be ( 3x2 + 3x1 + 5 + 4 + 5 + 5) / 6.
Your length of tokens starting with "a" would be 5.0.

Look elsewhere on this forum for keySet and you should be good to go.