```
int a = 30;
Integer b = new Integer(30);
if( b1 == b2)
    System.out.println("Hello");
else
    System.out.println("Hi");

```

> 
> Output : Hello
> 
> 
> 

Right. As a will also point to integer Object of b. Also explained here : [Comparing Integer objects](https://stackoverflow.com/questions/12547201/comparing-integer-objects)

But If I execute :

```
class A2
{
    public static void main(String args[])
    {
        int a = 30;
        Integer b1 = new Integer(30);
        Integer b2 = new Integer(30);
        if(a == b1 && a == b2)
            System.out.print("Hello");
        else
            System.out.print("Hi");
        if( b1 == b2)
            System.out.print("Hello");
        else
            System.out.print("Hi");
    } //End of Method
}// End of class

```

> 
> Output : Hello Hi
> 
> 
> 

Second Output is fine as now, b1 and b2 have separate objects. But now where will "a" point to ?? 
Please explain the reason of "Hello" output here.