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

Tried every combination

I'm either not understanding what you want or I have done something wrong. I have tried everything I can think of, preview is a blank page.

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

5 Answers

if statement syntax is: if (condition) { expression; }; So check first one thing and do some operation based on that check and if needed other checks. String firstExample = "hello"; String secondExample = "hello"; String thirdExample = "HELLO"; if (firstExample.equalsIgnoreCase(secondExample)) { console.printf("equal"); } .....

did that didn't work

just add another if statement the same way:

String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";

if (firstExample.equalsIgnoreCase(secondExample)) {
      console.printf("first is equal to second");
};
if (..........first and third) {
      console.printf("...");
};

if you do that your program will first check the first "if" statement and may do or may not do some operations based on the condition and then goes to the second "if" statement does the same thing

Over the class, I just unsubscribed, thanks for trying. This didn't work either by the way.

Francis Dwyer Give it another go, it will work. turaboy holmirzaev did not provide you with the full answer, but just gave you a hint to complete the second if-block yourself. So you'd need to modify that second if-block he wrote. The second challenge should have 2 if-blocks. You can do this!

first challenge:

String firstExample = "hello";
String secondExample = "hello";
String thirdExample = "HELLO";

if (firstExample.equalsIgnoreCase(secondExample)) {
      console.printf("first is equal to second");
};

It's the second challenge

Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

turaboy holmirzaev and Francis Dwyer this is my version

Part 1

// 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");
}
Tonnie Fanadez
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Tonnie Fanadez
UX Design Techdegree Graduate 22,796 Points

Part 2

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

//first part
if(firstExample.equals(secondExample)){
console.printf("first is equal to second");
}

//second part
if(firstExample.equalsIgnoreCase(thirdExample)){
console.printf("first and third are the same ignoring case");
}