# Kotlin Null Safety: Nullable Types and the `?` Operator
Kotlin's type system is designed to help prevent null pointer exceptions, a common source of errors in Java. It achieves this through **nullable types** and the use of the `?` operator.
## What are Nullable Types?
By default, a variable in Kotlin can hold only one value at a time. However, sometimes a variable might not have a value (it could be null). Nullable types allow you to declare that a variable *might* hold a null value. We denote this with the `?` suffix on the type.
**Example:**
```kotlin
var name: String? =
🟣 Kotlin Null Safety: Nullable Types and the ? Operator
Kotlin 문법
초급
난이도
문법
타입
10/12
등록일
Kotlin Null Safety: Nullable Types and the ? Operator
초급태그
코드 예제
```kotlin
// Example 1: Safe call to access a property
val address: Address? = getAddress(1)
val streetName = address?.streetName ?: \
등록일: 2025년 10월 12일 21:14
언어 정보
언어
Kotlin
카테고리
Mobile
인기도
#11
학습 팁
코드를 직접 실행해보세요
변수를 바꿔가며 실험해보세요
오류가 나도 포기하지 마세요
다른 예제도 찾아보세요