permaculture playing cards*
The moose likes Beginning Java and the fly likes very weird results from ternary operator... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "very weird results from ternary operator..." Watch "very weird results from ternary operator..." New topic
Author

very weird results from ternary operator...

Vinnie Jenks
Ranch Hand

Joined: Apr 26, 2004
Posts: 207
I have a ternary comparison that returns false no matter what I provide it and it makes absolutely no sense!

My code:



While debugging, "props.getProperty("is_locally_connected")" returns "true" (string, not boolean) yet isLocal always returns false once the code runs!

Am I loosing my mind? I've gotta be missing something from 24 straight hours of coding...I need someone to point out my stupidity here even though I've written these types of statements at least a billion times...

Thanks!
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Try this:


Mike Gershman
SCJP 1.4, SCWCD in process
Mike Gershman
Ranch Hand

Joined: Mar 13, 2004
Posts: 1272
Or this:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60810
    
  65

The problem is not with the ternary operator but with your understanding of what the == operator does.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
 
subject: very weird results from ternary operator...
 
Similar Threads
Conditional if
? ternary operator
?: doubt
Ternary
B&S - Must RMI and Local DB interfaces need to be different?