return « Boolean « Java Data Type Q&A

1. Boolean return method

i am doing computer science and in a project at the moment. I have had no code input for this as its specifically designed to mimic work i guess. I am ...

2. Returning boolean instead of declaring a void type in Java?

Are there any hard and fast rules regarding returning boolean in a method signature to indicate a successful operation as opposed to declaring void? I find that for more critical operations ...

3. Return Type Boolean in Java

I have a question on boolean return types. Check the following code:

Code Sample 1

boolean flag = sampleMethod();

public boolean samplemethod(){
    return false;

Code Sample 2


public boolean samplemethod(){
    return ...

4. Adapting methods which return true/false

What's the best practise when adapting C-style functions which return a true/false to Java? Here's a simple method to illustrate where the problem lies.

public static boolean fileNameEndsWithExtension( String filename, String fileExtension)  ...

5. Naming conventions for java methods that return boolean(No question mark)

I like using question mark at the end of method/function names in other languages. Java doesn't let me do this. As a work around, how else can I name boolean returning ...

6. What is returned if a boolean function fails?

Supposing a method:

public boolean setAttribute(){
  boolean returnval = false;
  object = this.getObject;                  ...

7. How do I use the Boolean values returned by a Java method?

I have a method that sends a bunch of characters to another method that will return true or false if certain character are present. Once this method evaluates all the ...

8. When should you use a method to return a value?

I'm fairly new to Java so forgive me for asking what may appear to be a stupid question. I am writing a simple 'user login' program. To check whether the username and ...

9. Using Boolean Value Returned

It's pretty easy to get mislead by reading code fragments, but the code fragment you show doesn't look like anything that will compile or execute, without seeing the surrounding class. For one thing, most implementations of getChar() return the character value, not the integer value. Here is a brief but complete program that has been run (on Java 5 aka 1.5 ...

10. Naming method which returns boolean

11. Returning and using booleans

I cant believe how much time ive spent trying to use Java's Booleans. In my opinion, C++ was much simpler here. First, what is the difference, if any, between a Boolean and a boolean? Can i even declare (or construct) or A boolean? What i would like to do is use a test function that test a condition or two and ...

12. Returning a boolean value

I am writing an applet that recieves two inputs and calculates whether the second input is a multiple of the first and then returns a value of true or false. So I believe I would have to convert my mod result from int to boolean and that is what I can't seem to figure out. or should I just return a ...

13. return Boolean

I have the following method in my Current class: //method to enable a withdrawal to be made public boolean withdraw (double amount) { System.out.println("Limit is: "+limit+" amount is: "+amount+ "newBalance is: "+newBalance); if (amount > newBalance) { System.out.println("Your balance of: "+newBalance+" is not enough to withdraw: "+amount); allowed = false; System.out.println("Boolean is returned as: "+allowed); return allowed; }//end if statement else ...

14. A boolean method and its returns values

this code works because you are garanteed to hit that "return bandera;" line. your other code example has a way for no "return xxx" to be hit. Garret said as much in his post. The compiler can't know what value will be passed in. all it knows is that if, somehow, someone passes in a 0 or less (which is a ...

15. boolean return question

16. return boolean

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.

18. Boolean Return Value

19. Boolean Return Value

20. Call a PL/SQL function that returns a boolean type using callablestatement.

Hi Anyone pls tell me , how to "I want to call a PL/SQL function that returns a boolean type, does anyone know how I can do this using a CallableStatement?" Java Code: // Call a function with two IN parameters; the function returns a boolean value true or false. CallableStatement proc_stmt = null; try { [COLOR="Red"]proc_stmt = connection.prepareCall("{? = call ...

21. Return Boolean

public class InnerInsulation { public InnerInsulation() { Scanner in = new Scanner(; CheckColour cl = new CheckColour(); if (cl.getUserColour() == 0 || cl.getUserColour() == 1) { System.out.println("Inner insulation is not available for the number of colour(s) choosen"); } else if (cl.getUserColour() == 2) { System.out.println("Would you like insulation?"); String insulation =; boolean wantsInsulation = (insulation.equalsIgnoreCase("Y") || insulation.equalsIgnoreCase("YES")); boolean noInsulation = ...

22. How do I make a method return a boolean?

[tutorials] make absolutely no sense to me! So... we're not likely to be a ship load of help then, are we? If you don't "get it" from a well researched and written set of tutorials what help are a pack of keyboard monkeys like us likely to provender? Dude... You HAVE to Read The Fucking Manual, it just goes with the ...

23. Boolean return type. Help please.

24. Returning and prinint a Boolean status

25. how to return a boolean in a method?

26. Method that returns boolean

27. boolean return value

28. How to return a message in a boolean method?

Ive run into a little issue with my search code. The code above is used to recursively search a binary tree. My trouble comes when I want to search the tree and then modify the node I find. What is happening is the info of the node is being displayed. Is there a better way of capturing a node's info than ...

29. a problem with a Method returning a boolean

30. best practise - using boolean check methods or methods that return null

I think there is no "correct" answer - it is situation dependant. I use method 1 a lot when just validating user input but if there is more business logic involved I try to keep it contained within the object that uses the value. For example, if I have an invoice object with a shipDate property and this date cannot be ...