vernon franks

Greenhorn
+ Follow
since Jul 28, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by vernon franks

Howdy yallll javacoffeecuppajoe here.....

I am learning intermediate Java and I am having confusion over one aspect of the instanceof operator. I know what it is used for and how to use it. What I am confused about though is why the operator cannot test for siblings in a class tree. Suppose I have a Class A, and Class B extends Class A. Then I make another class, Class C extends class A. Class B and Class C are siblings of Class A. It seems you cannot test instances of one sibling against the type of the other sibling. For instance:



The compiler complains of "Incompatible conditional operand types B and C" or something like that.


Why?
10 years ago