【評論主題】第9題Given:11. String[] elements = {"for", "tea", "too"};12. String firs
【評論內容】
三元運算子
(條件式) ? "符合條件的答案" : " 不符合條件的答案"
就像是if else
String[] elements = {"for", "tea", "too"};
String first = (elements.length0) ? elements[0] : null;
如果陣列的長度大於0的就讓字串first =elements[0],
而不滿足這個條件的就讓first=null
【評論主題】第9題Given:11. String[] elements = {"for", "tea", "too"};12. String firs
【評論內容】
三元運算子
(條件式) ? "符合條件的答案" : " 不符合條件的答案"
就像是if else
String[] elements = {"for", "tea", "too"};
String first = (elements.length0) ? elements[0] : null;
如果陣列的長度大於0的就讓字串first =elements[0],
而不滿足這個條件的就讓first=null