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 trialSophie Jiwan
787 PointsButton and TextEdit declaration
In the 'Make a Simple Android App' series, the mButton was declared, as well as initialized inside the OnCreate method, but in this series, the button and TextEdit are declared outside of the OnCreate, but used inside it. Why is this? Is one preferred over the other?
1 Answer
adamabdulghani
7,864 PointsHi Sophie, It depends on where you want to use the variables. I recommend you check out the Java courses or read on the difference between Global and local variables in Java.
Harry James
14,780 PointsHarry James
14,780 PointsMoved this as an answer :)