Java Java Basics Perfecting the Prototype String Equality

How do I make the IF statement check secondExample?

The question asks to use an if statement to check if the firstExample is equal to secondExample. So I tried if(firstExample == secondExample) , consoleprintf("the first is equal to the second") but it says its wrong... what did I do wrong?

Equality.java
// I have imported a java.io.Console for you, it is named console. 
String firstExample = "hello";
if(firstExample.equals("hello"));
  console.printf("first is equal to second");
String secondExample = "hello";
String thirdExample = "HELLO";

1 Answer

Steven Parker
Steven Parker
203,717 Points

Just put "secondExample" in the test method instead of duplicating the literal string. Also move the new code down after the variables are initialized.