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 trialArthur Podkowiak
3,633 PointsWhat is the point of mIsFinal
Why do you have to create a member variable that is just defined as a false boolean and then you change it to true. What was the point of that, I'm not understanding what mIsFinal
does for the code. And couldn't we just make the second Page
constructor not have Choice1 = null
and Choice 2 = null
? Because if it is only taking two arguments anyways, why do we have to add this?
1 Answer
minzawmra
Courses Plus Student 15,682 PointsmIsFinal
is initialised to false by default. It is set to true only when the second constructor Page(int ImageId, String text)
is called – you want it to stay 'false' if the other constructor is called. Alternatively, you can set mIsFinal
in the other constructor as 'false' instead of combining the declaration and initialisation.
You can leave the initialisation of Choice1 = null
and Choice2 = null
out from the constructor. They would be set to null by default anyway. Explicit initialisation is not necessary. I believe those two lines were added just for clarity.
Arthur Podkowiak
3,633 PointsArthur Podkowiak
3,633 PointsAhh I see. I also found out we used it later in the code. I personally don't think it would be necessary in THAT particular stage of the app, but it is necessary later as it will set a boolean to allow us to use a later method to take out the choice buttons. But thank you for the help!