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

Java Java Objects (Retired) Harnessing the Power of Objects Methods and Constants

Anyone can help me here? What's wrong and how I can solve this problem ?

Finally, let's add a method named charge. It should be public and return nothing. When called it should set mBarsCount to the value of the constant you declared in Task 1.

Bummer! There is a compiler error. Please click on preview to view your syntax errors!

GoKart.java
public class GoKart {
  private String mColor;
  private int mBarsCount;
  public static final int MAX_CHARGE = 8;

  public void setColor(String color) {
    mColor = color;            
  } 
  }
  public void Charge() {
    mBarsCount = MAX_CHARGE;
  }
  public String getColor() {
    return mColor;
  } 
}

2 Answers

Kourosh Raeen
Kourosh Raeen
23,733 Points

Hi Alex - You have an extra closing brace right before the charge method. Also, you've Capitalized the method name. That doesn't give you an error but it's not good practice. Also, the challenge asks you to initialize mBarsCount to zero in the constructor.

You should double check your code before asking a question.