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 trialjose huezo
Courses Plus Student 1,110 PointsPage page = mStory.getPage(0)
why at 0:25 we wrote "Page page = mStory.getPage(0);)" can somebody help me ?
2 Answers
Kevin Faust
15,353 PointsHey 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?
Kevin
dariabun
3,333 PointsOh my this helped me a lot. Thanks for the question and answer!
jose huezo
Courses Plus Student 1,110 Pointsjose huezo
Courses Plus Student 1,110 Pointsnow that make more sense, thank you very much!
Kevin Faust
15,353 PointsKevin Faust
15,353 PointsGlad it helped! Dont forget to mark as bes answer so others with the same question can see ^_^