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!
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 trial

Adnan Hasbi
4,544 PointsToast Notifications
Hi,
Doing the code challenge. The question is as follows :
Initialize the Toast variable using the static makeText() method of the Toast class. Use the βthisβ keyword for the first parameter, the text "All done!" for the second parameter, and the constant Toast.LENGTH_LONG for the third parameter.
My answer
Toast allDoneToast; Toast welcomeToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Please help
4 Answers

Ernest Grzybowski
Treehouse Project ReviewerLet's work through the problem together.
You are given:
Toast allDoneToast;
Then the first sentence reads:
"Initialize the Toast variable using the static makeText() method of the Toast class."
So it wants you to initialize the Toast variable that was given to you (allDoneToast). Note that it's telling you to use the "makeText()" method which is static. This let's you know that you don't initialize it like most other objects (aka: You don't use the 'new' keyword for statics) Which is done like this:
allDoneToast = Toast.makeText();
Then it tells you:
" Use the βthisβ keyword for the first parameter, the text "All done!" for the second parameter, and the constant Toast.LENGTH_LONG for the third parameter."
Which is pretty self explanatory.
allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Which gives you the final answer of:
The answer is:
Toast allDoneToast;
allDoneToast = Toast.makeText(this, "All done!", Toast.LENGTH_LONG);
Keep coding!

fabh
946 Pointsjust Toast.maketext
Michael Acosta Pegoraro
4,911 PointsThis helped, thanks!

Adnan Hasbi
4,544 PointsThank You sir :)