File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes return boolean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "return boolean" Watch "return boolean" New topic
Author

return boolean

john mor
Greenhorn

Joined: Mar 06, 2005
Posts: 11
Hi!
I have a little problem.

Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
Either you do it using logical operators or simply return true or false. But declaring a variable that will hold boolean values and manipulating it on whether or not it satisfies the condition would be the best option ( I guess )

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Disagree. Look in the Sun code conventions section 10.5.2 and you see that format is discouraged.

You should writeAs for printing out a boolean (or a Boolean) the PrintStream (= System.out.).print and println methods are overloaded to take a boolean argument.

If you prefer the printf methods (which you ought to use whenever possible) you find the %b tag will print a boolean as true or false. You can also use the %B tag which prints TRUE or FALSE! You can find a bit about printf in the Java Tutorials, and there is more detail (but less easy to read) in the Formatter class.
Hector Tenedero
Ranch Hand

Joined: Oct 13, 2008
Posts: 31
Thanks for the correction Ritchie . He can then just add additional equal() methods in the condition.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
You mean add more boolean values with && or || operators. Of course. What you are returning is (the result of) a plain simple boolean expression.

Obviously if the expression gets long, you would be better to have named boolean variables and put them together with operators, otherwise the expression will become incomprehensible.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: return boolean
 
Similar Threads
que on equals()
How to implement hashCode()
java problem
[newbie] Throwable Exception
hashcode and equals