I'm trying to understand this solution right here:
What I don't understand is what means == 0
??? And why it is: if it equals to 0?.
This was my task:
In leap years, February has 29 days instead of the usual 28 days. We can determine leap years by the fact that the year number is divisible by 4. However, the year must not be divisible by 100. If the year is divisible by 400, it is a leap year. Write a program in Java that checks whether a given year is a leap year. If the year is a leap year, true is output. If this is not the case, false is output.
I tried many things and then I wanted to look up from the solution and now I want to understand it.
import java.util.Scanner;
public class Leapyear {
public static void main(String[] args) {
Scanner TB = new Scanner(System.in);
System.out.println("Type in a year which you want to test if it is a leapyear or not:");
int year = TB.nextInt();
boolean isLeapYear = (year % 4 == 0 && year % 100 != 0) || year % 400 == 0;
System.out.println(isLeapYear);
}
}