11 Replies Latest reply: Nov 20, 2007 12:49 PM by 796440 RSS

    Problem with Calendar class..

    807603
      Have a look at the following code segment:


      Calendar a = Calendar.getInstance();
      Calendar b = Calendar.getInstance();
      a.set(11,14);
      a.set(12,30);
      System.out.println(a.get(11)+""+a.get(12));
      b.set(11,7);
      b.set(12,45);
      System.out.println(b.get(11)+""+b.get(12));
      System.out.println(a.get(11)+""+a.get(12));



      The output is:
      1430
      745
      745


      why does the object 'a' change when i am not manipulating it?????
      am i not allowed to create two different instances of the class Calendar???

      What should i do if i want two Calendar objects storing different information??
      Any related information will be helpful....