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 trialJames N
17,864 Pointsi need help
i need help . i do not understand the error i'm getting. here is my error: JavaTester.java:40: variable allDoneToast might not have been initialized else if (allDoneToast.mConstructorCalled) { ^ 1 error here is my code: Toast allDoneToast; Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
1 Answer
Stone Preston
42,016 Pointswhat task are you on? you are getting the error because you declare the variable allDoneToast but never assign it anything. if its task 1 you need to assign your second line to the declaration on the first. you also dont need to show it yet
//this never gets assigned
Toast allDoneToast;
Toast.makeText(this, "All done!", Toast.LENGTH_LONG).show();
to fix it just assign it the second like but remove the call to show
Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
James N
17,864 PointsJames N
17,864 Pointsthanks. i was on task 1
James N
17,864 PointsJames N
17,864 Pointsnow i am getting this error: JavaTester.java:32: incompatible types found : void required: Toast Toast smiley = Toast.makeText(this, ":)", Toast.LENGTH_LONG).show(); ^ 1 error with this code: Toast allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG); allDoneToast.show(); Toast smiley = Toast.makeText(this, ":)", Toast.LENGTH_LONG).show(); in task 3.
Stone Preston
42,016 PointsStone Preston
42,016 Pointsyou almost have it, you dont need to assign your third toast statement to a variable.
James N
17,864 PointsJames N
17,864 PointsTHANK YOU SO MUCH!!!