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) Meet Objects Constructors

Joshua De La Rosa
Joshua De La Rosa
2,721 Points

Confused on last quiz question i dont know how to setup the getColor method for my System.out,printf

GoKart mColor = new GoKart ("Red"); System.out.printf("%s");

Dont know what to setup beyond this?

4 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

The getColor method was created in the previous code challenge.

This is looking for you to just call it.

HINT: Something like this:

SomeObject something = new SomeObject();
System.out.printf("The result from the method is %s", something.getSomethingElse());
Joshua De La Rosa
Joshua De La Rosa
2,721 Points

holy jimminy christmas i did it thank you very much craig you were very helpful. I also understand the code much clearer.

Craig Dennis
Craig Dennis
Treehouse Teacher

You are very welcome! Glad it clicked!

I sat there for 30 minutes trying to figure out what I did wrong, only to realize I used "println" instead of "printf". If you're having a similar problem, double check that.

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Call your method getColor as the second param to printf

Joshua De La Rosa
Joshua De La Rosa
2,721 Points

Please show me the code to create the get color method. I have tried time and time agin there is something im not getting

I think there is a bug in the quiz. When I typed in what should have been marked as correct...

public class GoKart {
  private String getColor = "red";

public String getColor() {
  return getColor;
  }
}

... The message "Bummer! The method name should match more or less your field name. Expected getolor" So I had to change getColor to getolor to get credit.

public class GoKart {
  private String getolor = "red";

public String getColor() {
  return getolor;
  }
}

...and this ^^^ was counted as being correct. I logged into the quiz again to see if the same mistake came up and what came up was 'Bummer! The method name should match more or less your field name. Expected getetColor.

So I changed getColor to getetColor and what came up this time was ...'expected getetetColor'... so I changed it to getetetColor and then it wanted getetetetColor lol.

I`m having the same problem

Kevin Frostad
Kevin Frostad
3,483 Points

Agreed. They should fix that. Method names should not conflict with variable names.