Results 1 to 2 of 2

Thread: Converting Boolean values to string in Java

  1. #1
    Join Date
    Feb 2011
    Posts
    2

    Converting Boolean values to string in Java

    Hello everyone,

    I'm working a problem where I need to take a boolean true or false result and convert it into a variable of either even or odd based on calculations.

    I am able to print the statements out but I don't know how to convert the boolean = true to a string = Even.

    Is there a simple way to do this conversion?

  2. #2
    Join Date
    Feb 2011
    Posts
    2

    Re: Converting Boolean values to string in Java

    Here is the bit of code that I'm dealing with. Currenty I have the displayResults print statment just calling on my isEven method but I'm needing to convert it to True=Even, False=Odd. I've tried almost everything but I seem to keep getting a compliler error stating boolean to string incompatibility.

    public void displayResults ()
    {
    System.out.printf("\n%s:%s:%s\n", number, isEven ());
    }

    public boolean isEven ()
    {
    if ((number % 2) == 0)
    return true;
    else
    return false;
    }

Similar Threads

  1. Custom Boolean Values in Microsoft Excel
    By Thedevotee in forum MS Office Support
    Replies: 2
    Last Post: 15-02-2012, 05:05 PM
  2. Problem in creating array from string values
    By Cedric in forum Software Development
    Replies: 4
    Last Post: 19-01-2010, 05:48 PM
  3. Java - converting long into string format
    By Kingfisher in forum Software Development
    Replies: 5
    Last Post: 09-01-2010, 02:50 PM
  4. how to convert a boolean value to a string in java?
    By Janus in forum Software Development
    Replies: 3
    Last Post: 29-07-2009, 08:07 PM
  5. Need to convert string to ascii values with C#
    By Shashikant in forum Software Development
    Replies: 2
    Last Post: 02-02-2009, 07:14 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,133,325.93264 seconds with 16 queries