toStringmethod is automatically redefined to print the name of the case class and all its arguments,
equalsmethod is automatically redefined to compare two instances of the same case class structurally rather than by identity.
hashCodemethod is automatically redefined to use the
hashCodes of constructor arguments.
Most of the time you declare a class as a case class because of point 1, i.e. to be able to do pattern matching on its instances. But of course you can also do it because of one of the other points. The code example below makes use of two of the characteristics of case classes :
newkeyword (point 2), for example in
List(MyInt(1), MyInt(2), MyInt(3))
else m.asInstanceOf[MyInt].x == x;