package com.imooc;import java.util.Scanner;public class match { public static void main(String[] args) { Scanner input=new Scanner(System.in); System.out.println("Please input the score:"); int score=input.nextInt(); System.out.println("Please input the sex:"); String sex=input.next(); //int score=99; if(score>80) { if(sex=="m") System.out.println("Enter the man's final!"); else System.out.println("Enter the woman's fanal!"); } else { System.out.println("out!"); } }}
3 回答

产品经理不是经理
TA贡献481条经验 获得超143个赞
这里应该sex.equals("m")这样写,而不是sex=="m"。字符串比较,equals是比较内容是否相等,==是比较两个引用是否相等。
添加回答
举报
0/150
提交
取消