Re: [問題] && 和 &

看板java作者 (骨頭)時間19年前 (2006/08/18 20:38), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/4 (看更多)
※ 引述《seekyou (galagala~￾N )》之銘言: : public class ShortCircuit { : public static void main(String[] args) { : String s=null; : if((s != null) && s.length() > 20) && 是 前面的條件檢查 如果不符之後 就不會去檢查s.length() & 則反之 , 它會去檢查t.length() 因為t是null null 當然不能用.length() 就會出現nullPointerException : System.out.println(s); : String t=null; : if((t != null) & t.length() > 20) : System.out.println(t); : } : } : 如題,第一個if不會印出東西,(短路運算子) : 第二個if為什麼會有NullPointerException呢? : 謝謝回應 -- String temp="relax"; | Life just like programing while(buringlife) String.forgot(temp); | to be right or wrong while(sleeping) brain.setMemoryOut(); | need not to say stack.push(life.running); | the complier will stack.push(scouting.buck()); | answer your life stack.push(bowling.pratice()); | Bone everything -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.138.240.58
文章代碼(AID): #14vRIr7_ (java)
討論串 (同標題文章)
本文引述了以下文章的的內容:
以下文章回應了本文
完整討論串 (本文為第 2 之 4 篇):
文章代碼(AID): #14vRIr7_ (java)