try replacing
found = map.get(sequence);
if (found != null)
{
map.put(sequence,found + 1);
}
else
{
map.put(sequence,1);
}
with
if (map.containsKey(sequence))
{
map.put(sequence,found + 1);
}
else
{
map.put(sequence,1);
}
1. Your version would give an incorrect count, since found is never pulled from the map.
2. That's assuming that your version would compile. Which it won't. ("found" is never defined)
If I were to take a wild ass guess out of the blue, I'd come up with a single question: Kommi, how do you guarantee that you will always have
length characters to read from the screen? i.e. What happens if you want to read 10 characters, but only have 9 left?