-
Object Oriented
- Everything is an object.
- Unlike Java , where we have primitives/static fields and methods that are not members of any object.
Example: 1+2 is actually 1.+(2)
-
Functional
- Functions are first-class values or citizens.
- Encourages immutability where operations like map() , input values to output, rather than change data in place
-
Compatibility
- Compile to JVM bytecode
- Can call Java methods and fields
- Re-uses Java types
- Concise
class Time(val hours: Int, val inutes: Int)
public class Time {
private final int hours;
private final int minutes;
public Time(int hours, int minutes) {
this.hours = hours;
this.minutes = minutes;
}
public int getHours(){
return hours;
}
public int getMinutes() {
return minutes;
}
}