September 2015
Intermediate to advanced
250 pages
6h 40m
English
Scala provides full round-trip interoperability with Java. Because Scala compiles to bytecode, you can use Scala classes from Java quite easily. Remember, Scala does not by default follow the JavaBean convention, and you’ll have to use the @scala.reflect.BeanProperty annotation to generate getters and setters that conform to the JavaBean convention—see Defining Fields, Methods, and Constructors. Let’s look at how to use a method defined in Scala from Java.
Scala classes that follow standard Java constructs are pretty straightforward, and you can use them readily on the Java side. To illustrate intermixing from Java, let’s write a Scala class:
| Intermixing/Car.scala | |
| | package automobiles |
| | |
| | class Car(val year: ... |
Read now
Unlock full access