A HashMap stores data as key–value pairs, letting you look up a value quickly by its key instead of by position.