This question has already been answered:
- How to compare strings in java? 2 answers
import java.util.Scanner; public class Classwork { public static void main(String args[] ) throws Exception { Scanner stdin = new Scanner(System.in); int year = stdin.nextInt(); String month = stdin.next(); boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0); if(isLeapYear == true && month == "Feb") System.out.print(month + " " + year + " has 29 days"); else if(isLeapYear == false && month == "Feb") System.out.print(month + " " + year + " has 28 days"); switch(month){ case "Jan": System.out.print(month + " " + year + " has 31 days"); break; case "Mar": System.out.print(month + " " + year + " has 31 days"); break; case "Apr": System.out.print(month + " " + year + " has 30 days"); break; case "May": System.out.print(month + " " + year + " has 31 days"); break; case "Jun": System.out.print(month + " " + year + " has 30 days"); break; case "Jul": System.out.print(month + " " + year + " has 31 days"); break; case "Aug": System.out.print(month + " " + year + " has 31 days"); break; case "Sep": System.out.print(month + " " + year + " has 30 days"); break; case "Oct": System.out.print(month + " " + year + " has 31 days"); break; case "Nov": System.out.print(month + " " + year + " has 30 days"); break; case "Dec": System.out.print(month + " " + year + " has 31 days"); break; } } } When I enter 2222 Feb, it displays an empty value. Tell me what is wrong and what needs to be fixed?