boolean isGender = gender == "M";
此语句返回错误“无法比较的类型”之前的其余代码是
import java.util.Scanner;
public class BMR
{
public static void main(String[] args)
{
//Scanner
Scanner in = new Scanner(System.in);
//Get info
System.out.println("Enter your name: ");
String name = in.nextLine();
System.out.println("Gender (M or F): ");
String genderString = in.next();
char gender = genderString.charAt(0);
System.out.println("Enter your age: ");
int age = in.nextInt();
System.out.println("Height in inches: ");
int height = in.nextInt();
System.out.println("Weight in pounds: ");
int weight = in.nextInt();
System.out.println();
//calculate BMR
boolean isGender = gender == "M";
不知道为什么这不起作用