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

Android Build an Interactive Story App (Retired) Finishing the User Interface Loading the First Page

Page page = mStory.getPage(0)

why at 0:25 we wrote "Page page = mStory.getPage(0);)" can somebody help me ?

2 Answers

Kevin Faust
Kevin Faust
15,353 Points

Hey Jose,

Page page = mStory.getPage(0);)

mStory is the variable we created for the Story class. The Story class has a method called getPage() in the bottom of our Story class. We call that method, pass in a value from 0 to 6, and it will return the specified page that we wanted. In that method, it returns this:

return mPages[pageNumber]

So the number we pass in will the used to choose the array we want. In our Story class, we have an array of 7 pages. The first one is [0] and the last one is [6]. After we get the page we want, we store it in Page page where "Page" is the class type and "page" is the variable.

Does that make sense?


now that make more sense, thank you very much!

Kevin Faust
Kevin Faust
15,353 Points

Glad it helped! Dont forget to mark as bes answer so others with the same question can see ^_^

Oh my this helped me a lot. Thanks for the question and answer!