=60) result="passe_java条件表达式">
赞
踩
public class OperatorsAndExpressions_11 { String conditionalExpression(int score) { String result; result=(score>60)?"passed":"doesn't pass"; /*如果score超过60分,则结果是passed,否则是doesn't pass *该语句可以用if-else来替代,但是不够简练 *if(score>=60) result="passed"; *else result="doesn't pass" */ System.out.println(result); return result; } public static void main(String[] args) { // TODO Auto-generated method stub OperatorsAndExpressions_11 OperAndExp=new OperatorsAndExpressions_11(); //条件表达式 OperAndExp.conditionalExpression(65); } }
passed
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。