Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Conditionals. Any idea why I'm still getting numeric results instead of text?

Here's the portion of the code from the lesson.

Random randomGenerator = new Random(); //Construct a new random number generator int randomNumber = randomGenerator.nextInt(3);

            // if randomNumber equals 0 then
            if (randomNumber == 0) {
                // set answer to equal to Yes
                answer = "Yes";
            else if (randomNumber == 1) {
                answer = "No";
                else if (randomNumber == 2) {
                answer = "Maybe";
                else {
                    answer = "Sorry, there was an error!";

Thanks in advanced.

Stone Preston
Stone Preston
42,016 Points

can you post the portion of the code where you output the answer?

1 Answer

Stone, after reading your question I realized the problem. I didn't delete the integer line. I feel so dumb ha! Anyway, thanks again for replying quick and letting me realize the mistake :D

answer = Integer.toString(randomNumber);


Stone Preston
Stone Preston
42,016 Points

glad you got it figured out :)