© Toby Weston 2018

Toby Weston, Scala for Java Developers, https://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 class ...

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

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.