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

Anybody know where I went wrong here?

Not quite sure where I went wrong here lol a little help would be greatly appreciated. :)

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

  public GoKart(String color) {
    mColor = color;
    mBarsCount = 0;
  }

  public String getColor() {
    return mColor;
  } 

  public void charge() {
    mBarsCount = MAX_BARS;
}

2 Answers

Looks like your charge() method is missing its closing curly brace.

I cannot believe I missed that lol thanks for the help man haha I've been up too late xD

Its fine man, it happens to everyone eventually.

Cool man are you a Mobile developer?

No, but I am learning ios and swift right now on this website. But, I already have a lot of experience with Java from working with it in collage (as well as c, and c++). Once you get thing hang of a few c style languages its pretty easy to pick up new ones.

Nice, I wish I started off that way I hear people say if you can code in C and C++ you can code in just about anything. But any advice on how to get a good understanding of java for someone who is looking to get into android development?

It seems like your on the right track. Java is similar in a lot of ways to C, so if you are able to get a good understanding of that you should be able to learn other languages pretty easily. However I still think learning C is valuable because it gives you greater insight into why things are done certain ways. For example if you have ever wondered why arrays start at the index of 0, then learning C will give you a better insight since you can add to an array pointer to move to the next address in memory.

Like: int numbers[] = {1,2,3,4}; printf("The number %i\n, *(numbers + 2)); // will print 3

You can see that *(numbers + 2) is a lot like numbers[2]. Where 2 is an offset as far as the number of address spaces to move.

Hopefully I didn't just confuse you, but if you learn a language like C then you will learn little things like that. However learning Java will definitely take you a long ways. So just keep at it. It will eventually all start to make sense.

I see what you are saying there thanks for the help man have a good one.