• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Returning a boolean value

 
Ryan Perlman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just change your method signature to public boolean modulo()
Bosun
 
Ryan Perlman
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Junilu Lacar
Bartender
Posts: 7480
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
String.valueOf((num1 % num2) == 0); // KISF (Keep it simple, friend )

------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform
 
Cindy Glass
"The Hood"
Sheriff
Posts: 8521
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh all right!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic