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 trialUros Dukic
1,001 PointsCode challenge Toast problem
Can somebody help me with this challenge. I wrote the code: Toast toast = Toast makeText(this, "All done!", Toast.LENGTH_LONG);
And in preview I can find 6 errors...
Tnx
4 Answers
Stone Preston
42,016 Pointsyou named your toast variable wrong and you forgot the . between Toast and makeText.
you were supposed to use the variable that was there at the start of the challenge. when you start the challenge it looks like this:
Toast allDoneToast;
so then you just add the assignment to that, be sure and include the . between Toast and makeText
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
once you fix those two small issues you should be able to move on to the next task of the challenge
Stone Preston
42,016 Pointsdid you leave the code from the first two tasks in place? I tried using your code and passed just fine:
code for task 3:
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
allDoneToast.show();
Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
Uros Dukic
1,001 PointsI did it and still have one error.
JavaTester.java:31: allDoneToast is already defined in run() Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Stone Preston
42,016 Pointspost the code you have in your challenge. your code needs to look like this:
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
if you have something similar to whats below thats not correct. only declare it once.
//this is not correct. you have the same variable declared twice
Toast allDoneToast;
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Uros Dukic
1,001 PointsIn 3rd task I did it next way and preview show mi this error... Sorry guys if I am annoying but I really want to learn this...
Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show(); ^ Tnx.