Comparing a Boolean object to a boolean primitive
What will be the output of this code? Please explain how the Autoboxing or unboxing id done here.

    class MyBoolean
    {
        Boolean[] bool = new Boolean[5];
     
        public static void main(String[] args)
        {
          new MyBoolean().myMethod();
        }
     
        public void myMethod()
        {
          if(bool[1]==true)
          {
            System.out.println("It's true");
          }
          else
          {
            System.out.println("It's false");
          }
        }
    }
Comparing a Boolean object to a boolean primitive
===

What will be the output of this code? Please explain how the Autoboxing or unboxing id done here.

    class MyBoolean
    {
        Boolean[] bool = new Boolean[5];
     
        public static void main(String[] args)
        {
          new MyBoolean().myMethod();
        }
     
        public void myMethod()
        {
          if(bool[1]==true)
          {
            System.out.println("It's true");
          }
          else
          {
            System.out.println("It's false");
          }
        }
    }