Take your count variable outside the function—because of the scoping in Java, that variable gets deleted and refreshed as 1 each time you call the function to add the note, which then leads to update of the value for that key, which is 1.
static int count = 1;
public static boolean addNote() {
System.out.println("Enter a note to added ");
String note = scanner.nextLine();
if (myNotes.containsValue(note)) {
System.out.println("Note " + note + " already exists");
return false;
}
myNotes.put(count++, note);
System.out.println("Note added successfully");
return true;
}
Now this will work as you are expecting it to. Now in the main you can call the function multiple times.
Please check these links for more on this topic,
Interesting facts about Increment and Decrement operators in Java - GeeksforGeeks[
^]
Scope of Variables In Java - GeeksforGeeks[
^]