small medium large xlarge

A - flowers - 07_pragsmall
17 Sep 2012, 13:08
S. S. M. A. E (1 post)

Hi everybody.

Each java file with onCreate() method in this book, has PROTECTED access modifier, except the mainActivity (,that has PUBLIC onCreate.) Why they are “protected”?? i seek complete explaination, please.

Thanks for any idea. :)

04 Dec 2012, 15:39
Dmitriy Rodionov (2 posts)

Hi! I’m not a Java developer, but I suppose it has been made for the purpose of components sharing. As you might know, Android supports components sharing. Maybe you should mark onCreate() method as PUBLIC only when you want the Activity it creates to be shared other applications. I’m not sure…:-(

14 Apr 2013, 01:56
Ed Burnette (1341 posts)

In the book examples there was no good reason to make things public, protected, or private. In a real program, especially one with multiple developers, you should get in the habit of using the most restrictive access possible. Take a look at this:

You must be logged in to comment