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

Norbert Weinkauf
PLUS
Norbert Weinkauf
Courses Plus Student 2,293 Points

why this? There was a communication problem

whats the problem?

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.equalsTo(secondExample))
  console.printf("first is equal to second");

5 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! I'm not sure exactly why you're receiving a communication error. That is not what I receive when I try your code. Your code does, however, contain two errors. You have omitted the open and closed curly braces around your if body and equalsTo is not a valid string method. You are looking for equals().

Here's some pseudocode:

if(string1.equals(string2)) {
  //do something here
}

Hope this helps, but let me know if you're still stuck! :sparkles:

Norbert Weinkauf
PLUS
Norbert Weinkauf
Courses Plus Student 2,293 Points

Thanks for the quick answer, Jennifer.

But for one line after the if-statement I do not need the curly brackets?

Anyway always something like "oh no! communication problem... write an email at help. . " pops up.

So there are no error hints or corrections or something else. It just doesnt work. I am using firefox. maybe this is the problem? or some browser settings?

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

I sincerely doubt it's anything to do with your browser but rather with the inability of the code to compile. Have you tried restarting the challenge and refreshing the page?

I'm not sure what you mean by "for one line after the if statement", so I'll try my hint again.

if(thisThingIsTrue) {
  // code that executes if it is true
}
Norbert Weinkauf
PLUS
Norbert Weinkauf
Courses Plus Student 2,293 Points

I mean: if(age<2){ console.printf("it is a baby.") }

is the same as

if(age<2) console.printf("it is a baby.") //if there would be another line I would need the curved brackets

Even if it would be wrong some message should pop up. it doesnt compile.

Jennifer Nordell
seal-mask
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

If you're still receiving a communication error and you've tried restarting the challenge and refreshing the page, then you will likely have to contact support at help@teamtreehouse.com.

originally posted a statement saying that every if statement needed an open and closed curly brace, but apparently this was false

edited for accuracy

I stand corrected. I may have been confusing it with another language. You have my apologies. But you must still change the equalsTo to equals.

Norbert Weinkauf
PLUS
Norbert Weinkauf
Courses Plus Student 2,293 Points

Thanks again, Jennifer, for your quick help.

I should have had contacted the Support instead of posting here. ...and I haven't done it yet....

But the communication Problem of the "Code challenges" seems to be a browser Problem. In Microsoft Explorer, it works in Firefox not.

Jay Padzensky
Jay Padzensky
4,731 Points

I may recommend trying Google Chrome, as this browser tends to offer the smoothest experience with our app. If you prefer Firefox, try the Challenge again from a private viewing window. This will disable plugins/extensions that could hamper the CC's ability to properly test.