OOP Basics

The purpose of this workshop is to understand scala OOP part from Java Developer Perspective.We will see many examples on how easy it is to call java code from scala thus knowledge about java libraries is still valuable and you don't need to re-learn everything from scratch.

Declaring Classes

In this part we will see :

How to declare a class in scala

How to use java classes in scala

Java/Scala Byte Code Comparison

Constructors in scala

Final values and variables

Private state in classes

FILE : StarterOOP1ClassesInScalaDemo

Java classes can be used directly in scala code. In this first example we will Explain each part of scala declaration syntax.

val userJava:UserJava=newUserJava("John", 25)

Main differences from java

type is on the right side of a variable name

type can be interferred by compiler

no semicolons

val is like final in java

Compilation - Simple Classes Comparison

Because in scala you can put many public classes into an one file so our single demo file generate multiple classes. Let's compare interface generated from java code with the scala counterpart.