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 trialSerkan Erip
1,274 PointsWhy don't run this code
Where i am making mistake
Toast allDoneToast = Toast.makeText(this,"ALL DONE!",Toast.LENGTH_LONG).show();
4 Answers
Jon Kussmann
Courses Plus Student 7,254 PointsIf you want to display a toast, all you have to do is use what is on the right side of the '=' sign. There is no need to store it in a variable.
Toast.makeText(this,"ALL DONE!",Toast.LENGTH_LONG).show();
Seth Kroger
56,414 PointsThe "Toast allDoneToast =" part is expecting the expression that follows to return a Toast but the final method of the chain, show(), returns void. To make the challenge work you should split it into two lines.
Toast allDoneToast = Toast.makeText(this,"ALL DONE!",Toast.LENGTH_LONG);
allDoneToast.show();
Jillian Forde
3,138 PointsDid you get any output when you tried:
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG); allDoneToast.show();
I got a compile error with no output.
Serkan Erip
1,274 PointsYou're right but i am take compiler error! JavaTester.java:85: error: cannot find symbol else if (allDoneToast.mConstructorCalled) { ^ symbol: variable allDoneToast location: class JavaTester JavaTester.java:85: error: illegal start of type else if (allDoneToast.mConstructorCalled) { ^ JavaTester.java:88: error: cannot find symbol else if (!(allDoneToast.mContext instanceof JavaTester)) { ^ symbol: variable allDoneToast location: class JavaTester JavaTester.java:91: error: package allDoneToast does not exist else if (!allDoneToast.mText.toUpperCase().equals("ALL DONE!")) { ^ JavaTester.java:94: error: cannot find symbol else if (allDoneToast.mDuration == LENGTH_LONG) { ^ symbol: variable allDoneToast location: class JavaTester JavaTester.java:97: error: cannot find symbol else if (allDoneToast.mDuration != Toast.LENGTH_LONG) { ^ symbol: variable allDoneToast location: class JavaTester 6 errors
Serkan Erip
1,274 PointsSorry sorry i wrong understand because my english not well, i solved thank you for your comment!
Seth Kroger
56,414 PointsSeth Kroger
56,414 PointsThe challenge checker needs the allDoneToast variable to check that the Toast is being set up properly in prior stages. Otherwise, yeah the one line solution is better.
Jon Kussmann
Courses Plus Student 7,254 PointsJon Kussmann
Courses Plus Student 7,254 PointsGood point. I didn't check the instructions for the challenge.