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 trialKa Kai Chan
2,250 PointsFinally, write the 'message' variable to the log using the Log.d() method. For the first parameter of Log.d() (the tag),
What are the problems with my code?
String title1 = "Android is awesome";
String title2 = "Mike is cool";
String title3 = "Treehouse loves me";
String title4 = "message";
String[] titles = {"Android is awesome", "Mike is cool", "Treehouse loves me"};
String title4 = titles[1];
Log.d(โCodeChallengeโ, titles[1]);
2 Answers
Paolo Scamardella
24,828 PointsI just did the code challenge and it should be:
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);
You have the title1, title2, and title3 variables available and set, so you should use those to set your array and no need to retype those strings. Also, the exercise is asking you to add another variable called message and set it to the second element in the array, which the index is 1. At the end, it is asking you to use Log cat and use the message variable to print it out to the Log cat.
Hope this helps!
Ka Kai Chan
2,250 PointsI found out a problem. Thanks for your help!