title: A simple leap year logic trouble
body: <pre><code>public class LeapYear { 
      public static void main(String[] args) { 
          int year = Integer.parseInt(args[0]);
          boolean isLeapYear;
  
          // divisible by 4
          isLeapYear = (year % 4 == 0);
  
          // divisible by 4 and not 100
          isLeapYear = isLeapYear &amp;&amp; (year % 100 != 0);
  
          // divisible by 4 and not 100 unless divisible by 400
          isLeapYear = isLeapYear || (year % 400 == 0);
  
          System.out.println(isLeapYear);
      }
  }
  </code></pre>
  
  <p>I am passing <code>1900</code> as my input. The first condition evaluates to true as its divisible by 4, but again <code>1900</code> should be divisible by 100 too... </p>
  
  <p>How come i am getting 1900 as not a leap year.... what is the value being passed in the second &amp;&amp; condition... <code>(year % 100 !=0)</code></p>
  
  <p><strong>Update</strong></p>
  
  <pre><code>public class TestSample {
      public static void main(String[] args){
  
          int leapYear = Integer.parseInt(args[0]);
          boolean isLeapYear;
  
          isLeapYear = (leapYear % 4 == 0) &amp;&amp; (leapYear % 100 != 0);
  
          System.out.println("Its Leap Year" +isLeapYear);
  
      }
  
  }
  </code></pre>
  
  <p>Compiling this program prints <code>1900</code> not a leapYear How???? Here i am not even checking for the whether its divisible by 400 or not. </p>