Re: Parentheses issue
- From: "jupiter" <jupiter49byebyeSpam@xxxxxxx>
- Date: Sat, 30 Dec 2006 23:01:48 -0500
"Patrick May" <pjm@xxxxxxx> wrote in message
news:m2vejsztbf.fsf@xxxxxxxxxx
"jupiter" <jupiter49byebyeSpam@xxxxxxx> writes:
Can somebody explain in English
Will you accept geeklish?
Bring it on!
Nice explanation. Is that actually geekish? I've heard muchwhy 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;
}
The object member operator ('.') has higher precedence than
the
cast operator ('(...)'). The second form tries to call
getBalance()
before casting obj to the AccountBalance type.
worse, hehe.
Sorry for the lack of documentation; it was comparing doubles (orIn the second snippet the compiler complains of "incompatible
operand types, AccountBalance and double"
The error message is certainly not descriptive.
was supposed to be until the cast failed.)
Thanks, Patrick.
.
- References:
- Parentheses issue
- From: jupiter
- Re: Parentheses issue
- From: Patrick May
- Parentheses issue
- Prev by Date: Re: Parentheses issue
- Next by Date: Re: Looking for a starting point
- Previous by thread: Re: Parentheses issue
- Next by thread: MIDI OUT transmitter not available?
- Index(es):
Relevant Pages
|
|