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

Android Build a Blog Reader Android App Getting Data from the Web Getting JSON Data from an HTTP Request

Sam Soffes
STAFF
Sam Soffes
Treehouse Guest Teacher

Fails to compile in code challenge but works in Android Studio

For the code challenge:

Finally, set the 'responseData' String variable with the data in 'charArray'. Convert it using the String constructor that takes a char array as its parameter.

I do the following:

String responseData = new String(charArray);

In Android Studio it works just fine, but in the code challenge it doesn't work. Here's all of the code from the challenge.

2 Answers

Jonathan Baker
Jonathan Baker
2,304 Points

It's failing to compile because you have redeclared the variable named responseData. If you notice at the top of the code, responseData is already defined as String responseData = "". There is no need to redeclare it. =)