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
Charles Hill
Courses Plus Student 281 PointsSimple Refactoring
Hi. for Learning the Language > Simple Refactoring
In CrystallBall.java how do i fix illegal modifier on mAnswers
Code ScreenShots: http://i.imgur.com/aRGfAvk.png http://i.imgur.com/PzzgCMS.png
1 Answer
Ben Jakuben
Treehouse TeacherHi Charles,
Just remove public from the line where the error is. We can only use keywords like public, private, and protected for variables we declare at the class level (like private CrystalBall mCrystalBall in your MainActivity class). Variables we declare inside methods don't need any declarations like that because they only "live" inside their method. Their scope is constrained to that method, so they could never be public to any other code outside the method.
Hope this makes sense! Happy coding!