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
Ted Clayton
Courses Plus Student 206 PointsUsing string equality Challenge Task 2 of 2
Below is the question and my code along with the error. At first I thought I needed to put a curly brace at the beginning of the line after the print statement and it still didn't run. Please help provide a hint
Challenge Task 2 of 2 Add another if statement that checks if the firstExample is equal ignoring case to thirdExample. If it, is print out "first and third are the same ignoring case". A)if (firstExample.equalsIgnoreCase("HELLO")) { console.prinf("first and third are the same ignoring case. \n\n." ); JavaTester.java:135: error: illegal start of expression private static void pass() { ^ JavaTester.java:135: error: illegal start of expression private static void pass() { ^ JavaTester.java:135: error: ';' expected private static void pass() { ^ JavaTester.java:135: error: ';' expected private static void pass() { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:139: error: ')' expected private static void fail(String hint) { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: ';' expected private static void fail(String hint) { ^ 10 errors
5 Answers
Amulya Arora
6,133 Pointscan you please give the link to the challenge
Ted Clayton
Courses Plus Student 206 PointsTed Clayton
Courses Plus Student 206 Points// 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. \n\n");
if (firstExample.equalsIgnoreCase(thirdExample)) { console.prinf("first and third are the same ignoring case. \n\n." );
JavaTester.java:135: error: illegal start of expression private static void pass() { ^ JavaTester.java:135: error: illegal start of expression private static void pass() { ^ JavaTester.java:135: error: ';' expected private static void pass() { ^ JavaTester.java:135: error: ';' expected private static void pass() { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:139: error: ')' expected private static void fail(String hint) { ^ JavaTester.java:139: error: illegal start of expression private static void fail(String hint) { ^ JavaTester.java:139: error: ';' expected private static void fail(String hint) { ^ JavaTester.java:142: error: reached end of file while parsing } ^ 11 errors
Amulya Arora
6,133 PointsHey Ted, In the answer you have just given above: in the second task, you forgot to put the closing curly brace '}' of the if statement
if (firstExample.equalsIgnoreCase(thirdExample)) {
console.prinf("first and third are the same ignoring case. \n\n." );
The actual code should be:
if (firstExample.equalsIgnoreCase(thirdExample)) {
console.prinf("first and third are the same ignoring case. \n\n." );
}
I hope this helps...
Ted Clayton
Courses Plus Student 206 PointsAmulya, I used the curly brace as you said and still it wouldn't compile.