Before 1582 leap years are those divisible by 4.

After 1582 if the year is divisible by 4 it's a leap year.

Unless the year is divisible by 100 in which case it's not.

However if year is also divisible by 400 it's a leap year.

class LeapYear {
  public static void main(String[] args) {
    int year = Integer.parseInt( args[0] ); 
    if (year < 1582) {
      if (year % 4 == 0) {
        System.out.println( "Leap year." ); 
      } else {
        System.out.println( "Not a leap year." );
      } 
    } else {
      if (year % 4 == 0) {
        if (year % 100 == 0) {
          if (year % 400 == 0) { 
            System.out.println( "Leap year." ); 
          } else {
            System.out.println( "Not a leap year." ); 
          } 
        } else {
          System.out.println( "Leap year." ); 
        } 
      } else {
        System.out.println( "Not a leap year." ); 
      } 
    } 
  }
}

The if statement above can be simplified to: 

( (year < 1582) && (year % 4 == 0) ) || 
( (year >= 1582) && (year % 4 == 0) && 
                    (year % 100 == 0) &&
                    (year % 400 == 0) ||
  (year >= 1582) && (year % 4 == 0) && 
                    (year % 100 != 0))
)

Next we look at: 

int x = 18, y = 10; if (x < 10) { if (x > 5) y = 1; } else y = 2;

int x = 18, 
    y = 10; 

if (x < 10) {
  if (x > 5) {
    y = 1; 
  } else { 

  } 
} else {
  y = 2; // this is y at the end 
}

int x = 18, y = 10; if (x < 10) if (x > 5) y = 1; else y = 2;  

int x = 18, 
    y = 10; 

if (x < 10) {
  if (x > 5) {
    y = 1; 
  } else { 
    y = 2;
  }
} else {
             // that's our path 
}

Next we discussed this:

class One {
  public static void main(String[] args) {
    String a = "whatever", b = "whatever";
    a ="whatever";
    b = "what" + "ever";
    System.out.println( a + " = "+ b + " Answer: " + (a == b) );
  }
}

We noticed that the behavior was different from:

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> java LeapYear 2000
Leap year.
> 1 + 2
3
> (1 + 2) == 3
true
> "what" + "ever" 
"whatever"
> "whatever"
"whatever"
> "whatever" == "whatever"
false
> "whatever".equals("whatever")
true
>

Next time we start with: 

  P3.13 and 
 
  the three problems on the back of today's minute paper.   

Reading assignment for next time is: Chapter 4 (pages ...). 

--