Java Vs Kotlin
Features |
Kotlin |
Java |
1. Extension Functions |
It is already available in Kotlin |
In java, we need to create class |
2. Null Safety |
It
is available in Kotlin |
It
is not available in Java |
3. Static Members |
Kotlin doesn’t have a static member for a class |
It is available in Java |
4. String Templates |
Yes,
there are two types of string literals in Kotlin |
It
is available in Java too but it doesn’t support expression like Kotlin |
5. Wildcard Types |
It is not available in Kotlin |
Available in Java |
6. Smartcasts |
Available
in Kotlin |
Not
Available in Java |
7. No Checked Exceptions |
Kotlin removed exceptions entirely |
It is problematic in Java |
8. Operator Overloading |
Kotlin
allows users to provide a way to invoke functions |
Operators
are tied to particular Java Types |
9. Constructors |
It has primary constructor and secondary constructor |
Constructors can be used to take parameters to initialize
attributes |
10. Type System |
It
gives nullability support, type inference, and universal guards |
There
are other kinds of reference types related to the basic concept of class |
No comments: