三元運算子
Java 運算式說明章節
三元運算子 Ternary Operator
public class BinaryOperator{
public static void main(String[] args) {
boolean b1 = true;
String str1 = ( b1 ? "true" : "false");
System.out.println( "b1 為" + str1);
boolean b2 = !b1;
String str2 = ( b2 ? "true" : "false");
System.out.println( "b2 為" + str2);
}
}
b1 為true
b2 為false
【 M@nGo 留言區 】 如有任何建議的地方,請前往芒果留言區留言。
最后更新于