Syntax

Kotlin Nullable Type Syntax

In Kotlin, nullable type: allows a value to be null — var name: String? = null

Quick Answer

Syntax
var name: String? = null
KotlinSyntax

Nullable Type

Code example
var name: String? = null

Allows a value to be null.

Learn More

How to nullable type in Kotlin

  1. Open your Kotlin file or editor.
  2. Copy the example, then replace its sample names and values for your code.

Kotlin Nullable Type Syntax

Use var name: String? = null.

Related Syntax References

Frequently asked questions

What is the Kotlin syntax for nullable type?

Use this pattern: var name: String? = null

Can I copy this Kotlin code example?

Yes. Use Copy code and adapt the example to your program.

Is this Kotlin syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify