When multiple keys hash to the same bucket, collisions happen. HashMap uses a linked list or a balanced tree (for Java 8 and above) to handle collisions. In the event of a crash, it adds new elements to the existing bucket, thereby maintaining the order.