「Java」Null文字列を判定するサンプル

ソースコード
package com.arkgame;

public class StrNullD {

public static void main(String[] args) {

String sA = “", sB = “tokyo", sC = null;

System.out.println(isStrNull(sA));
System.out.println(isStrNull(sB));
System.out.println(isStrNull(sC));
}

public static boolean isStrNull(String s) {
return ((s == null) || (s.length() == 0));
}

}
結果
true
false
true

Software

Posted by arkgame