September 2015
Intermediate to advanced
250 pages
6h 40m
English
Java code often has a lot of boilerplate code—getters, setters, access modifiers, code to deal with checked exceptions…. The growing list bloats the code. As you’ll see here, the Scala compiler walks a few extra miles so you don’t have to expend efforts to write and maintain code that can be generated.
Scala has very high code density—you type less to achieve more. To contrast, let’s start with an example of Java code:
| FromJavaToScala/Greetings.java | |
| | //Java code |
| | public class Greetings { |
| | public static void main(String[] args) { |
| | for(int i = 1; i < 4; i++) { |
| | System.out.print(i + ","); |
| | } |
| | System.out.println("Scala Rocks!!!"); |
| | } |
| | } |
Here’s the output:
| | 1,2,3,Scala Rocks!!! ... |
Read now
Unlock full access