I saw this from a book
class AAA {
}
class BBB extends AAA {
    public static void main(String[] args) {
        BBB bb = new BBB();
        System.out.println(bb.equals((AAA) bb));  // true
        System.out.println(bb.equals((BBB) bb));  // true
    }
}
Simply speaking, BBB is a subclass of AAA.
but when an instance of BBB bb is created, I saw the className in bracket before the instance being used somewhere else. So I tested the equality, it seem that
bb is the same as both ((AAA) bb) and ((BBB) bb).
So why is this used? What is the purpose?
Thanks,