Skip to content

Instantly share code, notes, and snippets.

@hgfernan
Created July 16, 2021 15:49
Show Gist options
  • Save hgfernan/b66bf15c14ec780db9400b68d6242896 to your computer and use it in GitHub Desktop.
Save hgfernan/b66bf15c14ec780db9400b68d6242896 to your computer and use it in GitHub Desktop.
Invalid Java code showing a class accessing the private member of another class in the same package
/**
*
*/
package tPrivateProtected;
/**
* @author hilton
*
*/
public class IndependentProtectedClass {
protected int protectedMember;
protected IndependentProtectedClass() {
protectedMember = 1;
}
protected int sum(IndependentPrivateClass ipec) {
return protectedMember + ipec.privateMember;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment