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

Please tell me whats wrong here

String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO"; if (firstExample.equalsIgnoringCase(thirdExample)) { console.printf("first is equal to second"); }

Every time it keeps just saying its the . on the .equals

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.equalsIgnoringCase(thirdExample))
{
console.printf("first is equal to second");
}

2 Answers

It is equalsIgnoreCase not equalsIgnoringCase and you should change the sentence in the console.printf() to "first and third are the same ignoring case"

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

if(firstExample.equals(secondExample)){
  console.printf("first is equal to second");
}
if(firstExample.equalsIgnoreCase(thirdExample)){
  console.printf("first and third are the same ignoring case");
}
james south
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
james south
Front End Web Development Techdegree Graduate 33,271 Points

there is a note in gray above each challenge coding area telling you not to replace your code from previous tasks but to add to it. so leave your code from task 1 and add task 2 below it. then, you have the method name wrong, it is equalsIgnoreCase. finally, you have the string they want printed wrong, but it passed me anyway so that isn't critical.