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

Mr Sri
Mr Sri
9,200 Points

I keep getting the error: "Make sure you are using `equalsIgnoreCase` on the `firstExample` variable and use `console.p"

Can someone tell me why i keep getting the error ?

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(thirdExample.equalsIgnoreCase(firstExample)){ 
  console.printf("first and third are the same ignoring case"); 
} 

2 Answers

I checked that and it worked fine - that was my first thought too. It seems to be due to the first task's code having been deleted; I tried that too and got the errors described.

Steve.

Hi there,

I think it might be beause you deleted the first task's code. I passed the challenge with this:

// 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(thirdExample.equalsIgnoreCase(firstExample)){
  console.printf("first and third are the same ignoring case");
}

I hope that helps.

Steve.