DEV Community

Fahime Zivdar
Fahime Zivdar

Posted on

1

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)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay