In Kotlin, the type system distinguishes between references that can hold null (nullable references) and those that can not (non-null references).
Kotlinでは、型(type)の分類に対して、違った角度から見る方法(アスペクト/aspect)があります。
それは、nullを含めた場合の型(null許容型) と nullを含めない場合の型(非null許容型) で、分類する方法です。 
For example, a regular variable of type String can not hold null:
例えば、通常の String型 では、null を、含めません。(非null許容型) 

 #1 
fun main() {
    var a: String = "abc"
    a = null // compilation error(コンパイルエラー)
}

! Null can not be a value of a non-null type String
非null許容型のString型 には、null は、代入できません。
				Target platform: JVMRunning on kotlin v. 1.3.31
To allow nulls, we can declare a variable as nullable string, written String?:
null の、代入を許可するためには、「String?」 と書いて、「null許容型 の 文字列」 であることを示してください。

 #2 
fun main() {
    var b: String? = "abc"
    b = null // ok
    print(b)
}

null
				Target platform: JVMRunning on kotlin v. 1.3.31
Now, if you call a method or access a property on a, it's guaranteed not to cause an NPE, so you can safely say:
先の、変数a の、メソッド を呼ぶ、または、プロパティ に、アクセスする 時、NPE/NullPointerException が、起きないことは確実です。
(訳注:length は、Stringインスタンス の、プロパティ です)
ですから、以下のコードでは、エラーは発生しません。

 #3 
val l = a.length
But if you want to access the same property on b, that would not be safe, and the compiler reports an error:
でも、先ほどの 変数b の、プロパティ には、アクセス出来ないでしょう。
そして、コンパイルエラー になります。

 #4 
val l = b.length // error: variable 'b' can be null(エラー: 変数b はnullのはずです)
But we still need to access that property, right? There are a few ways of doing that.
でも、私たちは、そんなプロパティ に、アクセスしなければならない時がありますよね。
そのための、いくつかの方法が用意されています。


Checking for null in conditions(条件分岐 で null をチェックする)

First, you can explicitly check if b is null, and handle the two options separately:
第1の方法は、if式 を使って、変数b が、null であるのかどうかを、明確にチェックできます。
条件で、2通りに、分岐させることが出来ます。

 #5 
val l = if (b != null) b.length else -1
  (訳注:
	fun main() {
	    var b: String? = "abc"
	    b = null // ok
	    val l: Int = if (b != null) {
	        b.length
	    } else {
	        -1
	    }
	    print(l)
	}
  )
The compiler tracks the information about the check you performed, and allows the call to length inside the if. More complex conditions are supported as well:
コンパイラー は、あなたが行った if式 によるチェック を、調べます。
そして、そのif式の中でなら、プロパティlength に、アクセスすることを許可します。
たとえ、今のような if式よりも、複雑な条件分岐においても、コンパイラー は、同様に、サポートします。

 #6 
fun main() {
    val b: String? = "Kotlin"
    if (b != null && b.length > 0) {
        print("String of length ${b.length}")
    } else {
        print("Empty string")
    }
}

String of length 6
				Target platform: JVMRunning on kotlin v. 1.3.31
Note that this only works where b is immutable
ただし、これは、変数bの値 が、変更されていない部分でのみ、有効です。
(i.e. a local variable which is not modified between the check and the usage or a member val which has a backing field and is not overridable),
(言い換えれば、コードのロジックにおいて、再代入されてない ローカル変数 か、または、val で、定義されており、バッキングフィールド を持ち、そして、オーバーライドできない プロパティ のことです)
because otherwise it might happen that b changes to null after the check.
というのは、変数b が、その後、null に、変更されることは、起こりうるからです。
(訳注:backing field:バッキングフィールド:プロパティを保存する場所)


Safe Calls(安全呼び出し)
Your second option is the safe call operator, written ?.:
2つ目の方法は、「?.」 を、付けて実行する 安全呼び出し/セーフコール です。

 #7 
fun main() {
    val a = "Kotlin"
    val b: String? = null
    println(b?.length)
    println(a?.length) // Unnecessary safe call(不要な安全呼び出し)
}

null
6
				Target platform: JVMRunning on kotlin v. 1.3.31

This returns b.length if b is not null, and null otherwise. The type of this expression is Int?.
この例では、変数b が、null でなければ、文字列の数 を、返します。
null であれば、null を、返します。
つまり、この式が返す型 は、「Int?」 です。

Safe calls are useful in chains.
安全呼び出し は、返された結果をもとにして、複数回、続けることが出来ます。
For example, if Bob, an Employee, may be assigned to a Department (or not), that in turn may have another Employee as a department head, then to obtain the name of Bob's department head (if any), we write the following:
例えば、Bobが、従業員であるのかどうか?①、そうであれば、ある部署が、彼の所属であるのかどうか?②、そうであれば、その部署には、部長がいるのかどうか?③、ここまで来るのに、null に、出会わなければ、その部長の名前を取得します。
その場合のコードは、次のようです:

 #8 
bob?.department?.head?.name
Such a chain returns null if any of the properties in it is null.
このように連続して呼び出す場合(チェーン)、①・②・③ のどこかで、null が返されれば、null を、返します。

To perform a certain operation only for non-null values, you can use the safe call operator together with let:
null でない値にたいしてのみ、操作を行いたい時は、let関数 を使って、安全呼び出しを、しましょう。

 #9 
fun main() {
    val listWithNulls: List<String?> = listOf("Kotlin", null)
    for (item in listWithNulls) {
        item?.let { println(it) } // prints Kotlin and ignores null (Kotlin を、出力 null は、無視する)
    }
}

(訳注:
fun main() {
    val listWithNulls: List<String?> = listOf("Kotlin", null)
    for (item in listWithNulls) {
        if (item != null)
            println(item)
    }
}
)

Kotlin
				Target platform: JVMRunning on kotlin v. 1.3.31

A safe call can also be placed on the left side of an assignment.
安全呼び出し は、代入文の、左側に置くことも出来ます。
Then, if one of the receivers in the safe calls chain is null, the assignment is skipped, and the expression on the right is not evaluated at all:
その時、安全呼び出しのチェーンの中で、返す値が、1つでも null であれば、その時、その文に対する実行は、中断されます。つまり、右側の式に対しては、何も実行されないのです:

 #10 
// If either `person` or `person.department` is null, the function is not called:
(もし、「person」 か 「person.department」 が、null であれば、getManager()関数 は、呼び出しされません:)
person?.department?.head = managersPool.getManager()

Elvis Operator(エルビス演算子)
When we have a nullable reference r, we can say "if r is not null, use it, otherwise use some non-null value x":
null許容型 の、変数r がある時、「r が、null でなければ、その値 を使い、null であったならば、代わりのnullではない値x を使う」 ことが出来ます。

 #11 
val l: Int = if (b != null) b.length else -1

(訳注:
val l: Int = if(b != null) {
	b.length
} else {
	-1
}
)

Along with the complete if-expression, this can be expressed with the Elvis operator, written ?::
やや長いコードになる if文 と同じ事を、エルビス演算子?: を使って書くことが出来ます。

 #12 
val l = b?.length ?: -1
If the expression to the left of ?: is not null, the elvis operator returns it,
エルビス演算子?: の、左側の式 が、null でない場合は、そのnullではない値 を、返し、
otherwise it returns the expression to the right.
null の時は、そのエルビス演算子?: の、右側の式の値(この場合は、-1)を、返します。
Note that the right-hand side expression is evaluated only if the left-hand side is null.
ただし、エルビス演算子 の右側の式は、左側の値 が、nullの時のみ、評価(プログラムを実行すること)します。

Note that, since throw and return are expressions in Kotlin,
Kotlin では、throw句 も、return句 も、式 として扱えます。
they can also be used on the right hand side of the elvis operator.
よって、それらを、エルビス演算子 の、右側に置けます。
This can be very handy, for example, for checking function arguments:
この事は、例えば、関数の引数をチェックしたい時に、とても便利です。

 #13 
fun foo(node: Node): String? {
    val parent = node.getParent() ?: return null
    val name = node.getName() ?: throw IllegalArgumentException("name expected")
    // ...
}

The !! Operator(!!演算子)
The third option is for NPE-lovers:
3つ目の方法は、NullPointerException愛好家 のための方法です:
the not-null assertion operator (!!) converts any value to a non-null type
「!!」 は、「nullではないと(とりあえず)断言する演算子」 で、「どんな値」でも、「nullではないこと」 にします。
and throws an exception if the value is null.
そして、「その値」が、本当に null であるならば、 例外 を、発生させます。
We can write b!!, and this will return a non-null value of b (e.g., a String in our example)
「b!!」 と書くと、null ではない値 を、返すか(つまり、先ほどの例題コードでの、Stringインスタンス)、
or throw an NPE if b is null:
または、変数b が、null であるならば、例外 を、投げます(発生させます)。

 #14 
val l = b!!.length
Thus, if you want an NPE, you can have it, but you have to ask for it explicitly, and it does not appear out of the blue.
つまり、NullPointerException を、発生させたければ、そうすることは出来ます。
でも、その場合は、それが起きることを分かっていて実行してください。
そうすれば、突然起こってしまった、思いがけないエラーではなくなります。


Safe Casts(安全なキャスト)
Regular casts may result into a ClassCastException if the object is not of the target type. Another option is to use safe casts that return null if the attempt was not successful:
通常行う方法で、キャストすると、目的の型でなかった場合は、ClassCastException が、発生します。
(でも、)安全にキャストするために、もう一つの方法を使えば、目的の型にキャスト出来なかった場合(例外を発生させる代わりに)null を、返します。

 #15 
val aInt: Int? = a as? Int

Collections of Nullable Type(null許容型のコレクション)
If you have a collection of elements of a nullable type and want to filter non-null elements, you can do so by using filterNotNull:
null許容型の、コレクション(List, Map, Set) があるとして、null でない要素のみを、抽出したい場合は、
filterNotNull()メソッド を使えば、実現できます。

 #16 
val nullableList: List<Int?> = listOf(1, 2, null, 4)
val intList: List<Int> = nullableList.filterNotNull()