作者TonyQ (骨头)
看板java
标题Re: [问题] ?:问题
时间Mon Jun 19 05:42:23 2006
※ 引述《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