Skip to main content

New keyword for protected minus package visibility

4 replies [Last post]
tsinger
Offline
Joined: 2003-06-10

.. so only subclasses see the field/method, but no other member of the same package.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
wingetr
Offline
Joined: 2004-01-19

+1

Here are my propsed base access descriptors:

private - only that class has access
protected - only that class and subclasses have access
package - any class within the package has access
public - any class in any package has access

Allow package to be specified in addition to private and protected.

Maintain the default access descriptor as "package"

An inner class will have the same access privileges as its outer class.

tackline
Offline
Joined: 2003-06-19

New keyword? Why not "private protected"?

I'd like to see package be usable in place of the default, and not specifying access give a warning.

cowwoc
Offline
Joined: 2003-08-24

+1

Not specifying an access specifier should give a warning and package access should be explicitly assigned.

walter_bruce
Offline
Joined: 2004-11-19

Wouldn't it be easier to just put the class in its own
(sub)package within the main package.