File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Returning a boolean value" Watch "Returning a boolean value" New topic

Returning a boolean value

Ryan Perlman

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()

So much trouble in the world -- Bob Marley
Ryan Perlman

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
Cindy Glass
"The Hood"

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

Joined: Feb 26, 2001
Posts: 4446

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"

Joined: Sep 29, 2000
Posts: 8521
Oh all right!
I agree. Here's the link:
subject: Returning a boolean value
Similar Threads
First GUI program
Multiplying elements of two arrays together
Number calculations
Splitting an applet up into 2 classes
Action Performed Method