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 trialartursjansons
2,173 PointsChallenge task 4 of 4 in Android development – Blog Reader Project Overview
Hello. In this task I do receive a message saying “The second parameter (“String message”) of the Log.d() method must equal the value specified in the instructions” and instruction states that I need to use the “message” variable as the second parameter. Please see the code below;
String title1 ="Android is awesome"; String title2 ="Mike is cool"; String title3 ="Treehouse loves me"; String[] titles = { title1, title2, title3 }; String message = ""; message = titles[1]; Log.d("CodeChallenge", "titles[1]");
Can anyone please tell me what am I doing wrong ?
8 Answers
Valery Kukatov
6,996 PointsOh. Don't use quotes on message. Quotes turn it into a string basically.
Valery Kukatov
6,996 PointsMay be the space between String[] and titles = [title1...] is what causing the error?
artursjansons
2,173 PointsHi,
Not quite. The line that causes the error is -- Log.d("CodeChallenge", "titles[1]") --. As a second variable i need to use "message" variable so i did, however it still gives me an error.
Valery Kukatov
6,996 PointsI'm guessing what it's actually saying... instead of actually typing 'titles[1]' , you need to type in 'message'
artursjansons
2,173 PointsThats what i thought at first however it still doesn't work. Any ideas ?
Valery Kukatov
6,996 PointsLet's format your code and take it slow.
String title1 ="Android is awesome";
String title2 ="Mike is cool";
String title3 ="Treehouse loves me";
String[] titles = { title1, title2, title3 }; // Everything looks good till here.
String message = ""; message = titles[1]; /* I looked in the challenge and it
doesn't ask to input String message as blank.
Here you are assigning a blank message and then
assigning to message to be something else.
You are creating an unnecessary step */
Log.d("CodeChallenge", "titles[1]"); // Here you need to just replace 'titles[1]' with String 'message'
This worked for me.
artursjansons
2,173 PointsI'm clearly missing something. Sorry for being a pain but it still doesn't work for me, I've tried multiple times and variances, still nothing.
String title1 = "Android is awesome";
String title2 = "Mike is cool";
String title3 = "Treehouse loves me";
String[] titles = { title1, title2, title3 };
String message = titles[1];
Log.d("CodeChallenge", "message");
Thanks
artursjansons
2,173 PointsOMG, i finally did it!
Thank you for your help, much appreciated.