Last active
July 16, 2021 15:49
-
-
Save hgfernan/bc0fc05695d65878c99eac431c0aec34 to your computer and use it in GitHub Desktop.
Valid Java code showing a class accessing the protected member of another class in the same package that the former class is not not related by inheritance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
*/ | |
package tPrivateProtected; | |
/** | |
* @author hilton | |
* | |
*/ | |
public class IndependentPrivateClass { | |
private int privateMember; | |
private IndependentPrivateClass() { | |
privateMember = 1; | |
} | |
private int sum(IndependentProtectedClass iped) { | |
return privateMember + iped.protectedMember; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment