Hi guys, for example, I have class A, B extends A. I create an ArrayList<A> to contain both A and B
So when I check if an object is instance of BCode:ArrayList<A> lst = new ArrayList<A>();
lst.add(new B(args));
two conditions will be true. I wanna ask if there is any way to recognise that lst.get(0) is only an instance of B so the second condition should not be done.Code:if (lst.get(0) instanceof B) {
//Do something
}
else if (lst.get(0) instanceof A) {
//Do something
}
Thanks.

