Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark ""if" statment question  " Watch ""if" statment question  " New topic
Author

"if" statment question

G. Graz
Ranch Hand

Joined: Oct 23, 2006
Posts: 30
Is it possible to pass Boolean method as a parameter of another Boolean methods “if” statement ?. Basically I want to have a “if” statement execute if the parameter ( in this case the other Boolean method) is true. Something to this effect :
Janeice DelVecchio
Saloon Keeper

Joined: Sep 14, 2009
Posts: 1710
    
  12

Pretty sure you can.


When you do things right, people won't be sure you've done anything at all.
John de Michele
Rancher

Joined: Mar 09, 2009
Posts: 600
Yes you can. That's a common and acceptable idiom.

John.
G. Graz
Ranch Hand

Joined: Oct 23, 2006
Posts: 30
OK, great ! Thank you so much !
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39478
    
  28
You mean to use the return value of a boolean method as an expression. You don't call it a parameter there.

Note this alternative version of your code
 
Don't get me started about those stupid light bulbs.
 
subject: "if" statment question