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

RISHABH HURSHAN
RISHABH HURSHAN
737 Points

how to put ignorecase in if statment

i want 1st and 3rd to be compared

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==secondExample)
{
  console.printf("first is equal to second");
}
if(firstExample equalsIgnoreCase thirdExample)
{
  console.printf("first and third are same ignoring case");
}

2 Answers

William Li
PLUS
William Li
Courses Plus Student 26,868 Points

Here's how to do it, call the equalsIgnoreCase method on firstExample, and pass in thirdExample as argument to the method call.

if(firstExample.equalsIgnoreCase(thirdExample))
Chris 16
Chris 16
623 Points

Thank you William. These challenges stopping our progress of instruction could be a big negative for this site if it wasn't for the occasional other student helping, That seems to be a lack of instructor help from a PAID FOR program,