我已经制定了一个程序来根据月份来判断它是什么季节。但是,无论我输入什么,它都说是秋天。这是代码:
import java.util.Scanner;
public class SeasonChecker {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.println("What month is it??");
String month = input.nextLine();
System.out.println(month);
if (month == "december"||month == "January"||month=="February"){
System.out.println("Then it is Winter?");
}
else if (month=="March"||month=="May"||month=="April"){
System.out.println("Then it is Spring!!!");
}
else if (month=="June"||month=="July"||month=="August"){
System.out.println("Then it is Summer!");
}
else {
System.out.println("Then it is Autumn!");
}
input.close();
}
}