Created
          August 8, 2025 13:37 
        
      - 
      
- 
        Save verhas/ffbb785deb80befe105a783653e8ab86 to your computer and use it in GitHub Desktop. 
    a simple private access demo
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | public class OverridePrivate { | |
| private static class A { | |
| private void foo() { | |
| System.out.println("foo"); | |
| } | |
| private void bar() { | |
| System.out.println("bar"); | |
| } | |
| } | |
| private static class B extends A { | |
| private void foo() { | |
| System.out.print("B "); | |
| super.foo(); | |
| } | |
| } | |
| public static void main(String[] args) { | |
| A a = new A(); | |
| B b = new B(); | |
| a.foo(); | |
| a.bar(); | |
| b.foo(); | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment