views:

1124

answers:

2

If I have a java class which is package-private (declared with "class", not "public class"), there is really no difference if the methods inside are declared public or protected or package-private, right? So which should I use, or when should I use which? I'm a bit confused.

A: 

Public methods inside a package class are public to classes in the same package. But, private methods will not be accessible by classes in the same package.

Jeremy Powell
+4  A: 

Well maybe not immediately. But if you then (or in the future) declare a 'protected' or 'public' class that inherits from the package-private class, then the visibility of the members of the original class do matter.

Stephen C