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

Android Build a Simple Android App (2014) Improving Our Code Adding More Colors

Ben Holland
PLUS
Ben Holland
Courses Plus Student 4,062 Points

My color wheel has an error and i dont why ?

heres the code for my ColorWheel.java

package com.ben.funfacts.funfacts;

import android.graphics.Color;

import java.util.Random;

/**
 * Created by stevenphillips on 05/11/14.
 */
public class ColorWheel {


    // Member Variables

    public String mColors[] = {
            "#39add1", // light blue
            "#3079ab", // dark blue
            "#c25975", // mauve
            "#e15258", // red
            "#f9845b", // orange
            "#838cc7", // lavender
            "#7d669e", // purple
            "#53bbb4", // aqua
            "#51b46d", // green
            "#e0ab18", // mustard
            "#637a91", // dark gray
            "#f092b0", // pink
            "#b7c0c7"  // light gray
    };

    // Method ability
    public int getColor()  {





        String color = "";


        // Randomly Select Fact
        Random randomGenerator = new Random(); // Construct new Random generator
        int randomNumber = randomGenerator.nextInt(mColors.length);

        // Facts

        color = mColors[randomNumber];
        int colorAsInt = Color.parseColor(color);

        return colorAsInt;

    }

I fixed your code a bit. To learn how to markdown code in the forum you can check out the video on the right side :)

1 Answer

Hi again Ben, your code seems fine but you have missed a brace in the end. Try adding a "}" in the end and see if that helps.

You are welcome :)