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 trial

Android Threads and Services But Wait There's More! Foreground Services

Is there any reason to create the notificationBuilder variable in this video?

In the video the notification was created with with this code:

Notification.Builder notificationBuilder = new Notification.Builder(this);
Notification notification = notificationBuilder.build();

But as far as i know creating the builder variable is not necessary, and the same thing can be done like this:

Notification notification = new Notification.Builder(this)

Is there any reason (style / performance ) to write out the longer version?

edit: It seems the longer version was only used for educational purposes - the same project is used in the next course ( Intents and Receivers ) and the code will be rewritten to the shorter version to take advantage of the "fluent interface".

I'll leave the question up though, in case i was wrong.