-
private
Hi all, I' m new in forum, i have a problem i need your help:
//File Fin.java
class Base{
private void amethod(){
System.out.println("amethod");
}
}
public class Fin extends Base{
public final void amethod(){
System.out.println("Fin: amethod");
}
public static void main(String argv[]){
Base b = new Base();
b.amethod();
}
}
The error is: amethod() has private access in Base. I know if i delete private it could access, but i must keep private and find a different way to run this program without errors... Any ideas ?:confused:
P.S: Sorry for my English.
-
Code:
class Base{
private void amethod(){
System.out.println("amethod");
}
public void accessAmethod() {
amethod();
}
}
public class Fin extends Base{
public final void amethod(){
System.out.println("Fin: amethod");
}
public static void main(String argv[]){
Base b = new Base();
b.accessAmethod();
new Fin().amethod();
}
}