nullキーワード
Processingにおけるnullキーワードは、ターゲットを示すために使用される特別な値で有効なデータ要素ではありません。
処理中に、そこにないデータにアクセスしようとすると、nullキーワードを渡って実行することができます。
Processingで使用するnullキーワードの使い方は以下の通りです。
String content = "It is abeautiful day.";
String[] results; // 空の文字列配列を宣言する
results = match(content,"orange");
// 上記のmatchステートメントは、文字列 'content'に
// "orange"という単語が見つからないため、結果にnull値を返します。
if (results == null) {
println("Value of 'results' is null."); // この行は印刷されています
} else{
println("Value of 'results' is notnull!"); // この行は印刷されません
}
図2:プログラムk実行結果