Skip to content

Instantly share code, notes, and snippets.

@hgfernan
Last active July 16, 2021 15:49
Show Gist options
  • Save hgfernan/bc0fc05695d65878c99eac431c0aec34 to your computer and use it in GitHub Desktop.
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
/**
*
*/
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