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

Getting error after running boolean check

Hi after running Boolean check within the java-repl screen it returns true as expected but then any further commands or check that are carried out return error. see below. Why has it become an error running this check and how is this resolved without closing and reopening the screen.

treehouse:~/workspace$ java-repl
Welcome to JavaREPL version 282 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_20)
Type expression to evaluate, :help for more options or press tab to auto-complete.
java> String someWordis = "this is a bunch of WORDS!";
java.lang.String someWordis = "this is a bunch of WORDS!"
java> String someWords = "This is a bunch of Words!";
java.lang.String someWords = "This is a bunch of Words!"
java> boolean= someWords.contains("This")
java.lang.Boolean boolean = true
java> someWords.contains("Thids is")
ERROR: <identifier> expected
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");

java> someWords.contains("Thids is")
ERROR: <identifier> expected
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
java> return
ERROR: <identifier> expected
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^

ERROR: <identifier> expected
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of type
public java.lang.Boolean boolean = valueOf("boolean");
^
ERROR: illegal start of expression
return;
^

1 Answer

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Rehan!

Looks like you found a little bug in the REPL. When you typed:

 boolean= someWords.contains("This")

You forgot the variable name...I think you created a boolean named boolean which isn't allowed in Java, but somehow the REPL let you do it ;)

Try it again with a valid variable name like this:

boolean doesItHaveWord = someWords.contains("This");