Java Java Basics Perfecting the Prototype String Equality

Tre Peterson
Tre Peterson
314 Points

Not sure where I went wrong

Not showing up as error on the previews. So not sure where the errors are

Equality.java
// I have imported a java.io.Console for you, it is named console. 
String firstExample = "hello";
String secondExample = "hello";
if (secondExample.equals("hello")){
  console.printf("first is equal to second.");
  System.exit(0);
}
String thirdExample = "HELLO";
Tre Peterson
Tre Peterson
314 Points

Question was Add an if statement that checks to see if firstExample is equal to secondExample. If it is, print out "first is equal to second".

1 Answer

Simon Coates
Simon Coates
3,092 Points

The exit statement is probably messing things up. Moving the third string further up would make sure it is assigned a value, but doesn't seem to alter whether it passes validation. So I'd guess the exit short-circuits their validation code.