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 Basics Perfecting the Prototype String Equality

Herbert Keijman
Herbert Keijman
702 Points

What's wrong with this code?

I checked the make sure advice but it's still not working

Equality.java
// I have imported a java.io.Console for you, it is named console. 
String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";

if(firstExample.equalsIgnoreCase(thirdExample)) {

  console.printf("first and third are the same ignoring case");

}
Tomas Schlepers
Tomas Schlepers
18,039 Points

I think the problem is with the console.printf command.

In Java, to print something to the console, I usually use System.out.println

I think console.printf is a combination between JavaScript (console) and Java (printf). Let me know if this was the fix :)

Herbert Keijman
Herbert Keijman
702 Points

I think using System.out.println is correct but in this course they use console.printf

1 Answer

Alexander Nikiforov
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 Points

Your task 2 of challenge is correct, however you have to leave the first task done as well:

Please add to your code solution of the first task

"Add an if statement that checks to see if firstExample is equal to secondExample. If it is, print out "first is equal to second".