1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
public class emptystring { public static void main(String[] args) { System.out.println("null".equals(n(0) + "")); System.out.println("null".equals("" + n(0))); System.out.println("x".equals(n(1) + "")); System.out.println("x".equals("" + n(1))); } static String n(int i) { if (i==0) return null; else return "x"; } }