Значение хеш-таблицы не уменьшается на 1 во втором цикле над массивом maga_split, они остаются такими же, как в первом цикле.
Hashtable<String,Integer> notemap=new Hashtable<String,Integer>();
String[] note_split = {give,one,grand,today};
String[] maga_split = {give,me,one,grand,today,night};
for(int i=0;i<note_split.length;i++)
{
if (!notemap.contains(note_split[i]))
{
notemap.put(note_split[i],1);
}
else
{
notemap.put(note_split[i],notemap.get(note_split[i])+1);
}
}
for(int i=0;i<maga_split.length;i++)
{
String s=maga_split[i];
if (!notemap.contains(s))
{
notemap.put(s,1);
}
else
{
notemap.put(s,notemap.get(s)-1);
}
}
for(Map.Entry s:notemap.entrySet())
{
System.out.println(s.getKey()+" = "+s.getValue()); }




Ваш код не работает, потому что вы используете notemap.contains(). Если вы читали документацию для contains():
Tests if some key maps into the specified value in this hashtable. This operation is more expensive than the containsKey method. Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).
Таким образом, вы не проверяете, находится ли ключ в таблице, вместо этого вы проверяете значение.
При использовании карт рекомендуется использовать по возможности используйте интерфейс Map: Map<String, Integer> notemap = new HashMap<>();. Таким образом, вы можете быть уверены, что вызываете стандартный интерфейс для карты, и при необходимости можете переключить реализацию карты, например, с HashMap на TreeMap.
Тогда вы должны использовать метод containsKey()
Пожалуйста, включите определение notemap