Parentheses issue
- From: "jupiter" <jupiter49byebyeSpam@xxxxxxx>
- Date: Sat, 30 Dec 2006 20:23:48 -0500
Hi guys,
Can somebody explain in English why the cast of obj to
AccountBalance works here?
if(obj instanceof AccountBalance &&
((AccountBalance)obj).getBalance() == this.balance) {
return true;
}
But doesn't work here?
if(obj instanceof AccountBalance &&
(AccountBalance)obj.getBalance() == this.balance) {
return true;
}
In the second snippet the compiler complains of "incompatible
operand types, AccountBalance and double" so it is apparently not
even noticing the obj.getBalance() method. Or maybe it needs to
only weigh the leftmost object versus the right hand operand, and
I've separated or broken up the lefthand operand? I expected that
the cast would be applied first, making obj a type of
AccountBalance, and then getBalance() would be parsed.
Not true but I don't know why.
.
- Follow-Ups:
- Re: Parentheses issue
- From: Patrick May
- Re: Parentheses issue
- From: Andrew
- Re: Parentheses issue
- Prev by Date: Re: Word Count app using tokenizer (Java)
- Next by Date: MIDI OUT transmitter not available?
- Previous by thread: Map.get(key) returns null after inserting key
- Next by thread: Re: Parentheses issue
- Index(es):
Relevant Pages
|