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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Rodrigo Gomez-Palacio](https://secure.gravatar.com/avatar/750ecf0e96f1e2a7964935815e05bc10?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Rodrigo Gomez-Palacio
1,125 PointsCode is not accepting my answer
The error message I am getting is "Please print out the message using the System.out object."
I thought I did use the system.out object!
public class Main {
public static void main(String[] args) {
GoKart kart = new GoKart("yellow");
if (kart.isBatteryEmpty()) {
System.out.println("The battery is empty");
}
try{
kart.drive(2);
}
catch(IllegalArgumentException iae){
System.out.println("Not enough battery");
}
}
}
2 Answers
![qlpxjevhuv](https://secure.gravatar.com/avatar/5d2ac7e2cda8c5379923fa118d0d82c5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
qlpxjevhuv
10,503 PointsYour code is set up the correct way, but you aren't getting the error message from IllegalArgumentException.
System.out.printf("Experiencing an error: %s", iae.getMessage());
![Jess Sanders](https://secure.gravatar.com/avatar/a6166c9bd67f8457d9e8899067dac4a5?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Jess Sanders
12,086 Pointstry {
dispenser.load(400);
} catch (IllegalArgumentException iae) {
System.out.println("Whoa there!");
System.out.printf("The error was: %s%n", iae.getMessage());
}
Above, is the code example to follow. Instead of dispenser.load(400), you are trying kart.drive(2)