Re: [問題] ?:問題
※ 引述《justinC (無)》之銘言:
: int a=1;
: a>=1?System.out.print("YES"):System.out.print("NO");
: 我在java用這種寫法不行
: 但在c++上的a>=?cout<<"yes":cout<<"no";卻可以
: 請問java的三元運算子的使用(特性)是否有一點點較其他語言不同?
System.out.println( (a>=1)?"YES":"NO");
Java的 ?: 主要使用於傳值 , 而非執行動作.....
--
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
討論串 (同標題文章)
java 近期熱門文章
PTT數位生活區 即時熱門文章