A scenario about the calendar in Java in which explicitly setting a date leads to some diffrent result
<p>Let's look at the following code snippet in Java.</p>

<pre><code>package demo;

import java.util.Calendar;

final public class Main
{
    public static void main(String[] args)
    {
        Calendar cal = Calendar.getInstance();
        cal.set(2011, 11, 11);   //Setting a date to itself.

        System.out.println(cal.get(Calendar.YEAR) + " " 

        + cal.get(Calendar.WEEK_OF_YEAR) + " 

       " + cal.get(Calendar.DAY_OF_YEAR));
    }
}
</code></pre>

<hr>

<p>In the above simple code, I'm temporarily (and <strong>explicitly</strong>) setting the current date to itself which is 2011-11-11 using the method <code>cal.set(2011, 11, 11);</code>. Accordingly, I get the output <strong>2011 51 345</strong>, the current year <strong>2011</strong>, the week of the year <strong>51</strong> and the day of the year <strong>345</strong>. </p>

<hr>

<p>When I leave a comment on that line which is <code>cal.set(2011, 11, 11);</code>, I get the result, <strong>2011 46 315</strong> the current year, the current week of the year and the current day of the year respectively which is different from the earlier result. </p>

<p>[Here, I'm not setting any date. The statement <code>cal.set(2011, 11, 11);</code> in the above code is commented out and the system is automatically retrieving the current date which is 2011-11-11].</p>

<hr>

<p>In both the cases, the same date is used which is <strong>2011-11-11</strong> still the result obtained is different in both of the cases. Why?</p>
