Two Laptop Bag*
The moose likes Beginning Java and the fly likes Returning a boolean value Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning a boolean value" Watch "Returning a boolean value" New topic
Author

Returning a boolean value

Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
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 string of "true" or "false" here is the code I have written so far but I am still changing it now.

Thank you Ryan Perlman
(edited by Cindy to format code)
[This message has been edited by Cindy Glass (edited November 05, 2001).]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Just change your method signature to public boolean modulo()
Bosun

Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
what to use to convert boolean to string from my modulo method.
resultField.setText(Boolean.toString(???); mod or result but neither work cannot resolve symbol. Stuck
Ryan
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
If you want to take in a int value and return a boolean you set it up like:

Then to use it
String answer = Boolean(modulo(number2 % number1)).toString();
This feeds the remainder into the modulo method as an int and returns a boolean, converts to a Boolean and gets the String value of it.


"JavaRanch, where the deer and the Certified play" - David O'Meara
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4456
    
    6

String.valueOf((num1 % num2) == 0); // KISF (Keep it simple, friend )

------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform


Junilu - [How to Ask Questions] [How to Answer Questions]
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Oh all right!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Returning a boolean value