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

Can tell me what I'm do wrong in this Java Basic challenge.

What's wrong with this code?

String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO"; if (firstExample.equals(secondExample)) { console.printf("first is equal to second\n\n"); System.exit(0); }

I'm expecting it to print "first is equal to second" to the console.

What error are you getting, or what is actually happening? This looks fairly straightforward, but that info may be helpful.

HI Wendell

I've copied and pasted your code into a workspace and it returned the the string you expected.

I think as Kyle has said the exact error message may help us identify the issue.

3 Answers

I've have been running this code challenge myself just a moment ago. You should be leaving the System.exit out of there.

Hope this helps.

Thanks Michael, Once I removed the System.exit it was all good.

You're welcome!

I've reviewed your code for a few minutes, and the most prominent issue I'm seeing is that you're trying to print to the command line using console.prinf(...). My guess is that you need System.out.println(...) instead. This is the more conventional way of printing to the console.

Your logic all looks fine, let me know if this isn't what you're looking for.

I think you would normally be right but within this course it demonstrates using console.printf()