© Toby Weston 2018
Toby WestonScala for Java Developershttps://doi.org/10.1007/978-1-4842-3108-1_4

4. Scala’s Class Hierarchy

Toby Weston
(1)
London, UK
 
Scala’s class hierarchy starts with the Any class in the scala package. It contains methods like ==, !=, equals, ##, hashCode, and toString.
  abstract class Any {
    final def ==(that: Any): Boolean
    final def !=(that: Any): Boolean
    def equals(that: Any): Boolean
    def ##: Int
    def hashCode: Int
    def toString: String
    // ...
  }
Every class in Scala inherits from the abstract class Any. It has two immediate subclasses, AnyVal and AnyRef, as shown in Figure 4-1.
A456960_1_En_4_Fig1_HTML.jpg
Figure 4-1
Every ...

Get Scala for Java Developers: A Practical Primer now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.