若是寫成:StringBuffer s = null; System.out.println(s.append("")); java
就會報出:java.lang.NullPointerException 空指針異常。app
必須:StringBuffer s = new StringBuffer();指針