DEV Community

Fahime Zivdar
Fahime Zivdar

Posted on

Difference null-safety in java and kotlin

The kotlin is null-safety unlike java
In the java the codes in compile time they are null .So that's why may occurNullPointerException.
For example: when defined a variable. the variable may be null
To avoid being null variable.
We have to use @notnull .and then variable is safe.
In the kotlin by default all of thing is not null.
When defining a variable, we can define the initial value in Nullable.
Before compiling because IDE Is smart, checks Nullable

Top comments (0)