Results 1 to 2 of 2
Thread: private
- 01-29-2010, 12:52 AM #1
Member
- Join Date
- Jan 2010
- Posts
- 1
- Rep Power
- 0
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.
- 01-29-2010, 01:42 AM #2Java 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(); } }
Similar Threads
-
private array
By tnght in forum New To JavaReplies: 10Last Post: 12-05-2009, 09:43 AM -
More than one input in one private method
By rice in forum New To JavaReplies: 0Last Post: 10-02-2009, 06:08 AM -
Private constructor and super()
By Basit56 in forum Advanced JavaReplies: 9Last Post: 08-21-2009, 07:19 AM -
Private Classes Clarification
By justlearning in forum New To JavaReplies: 1Last Post: 05-06-2008, 11:51 PM -
Question of private member
By Felissa in forum Advanced JavaReplies: 2Last Post: 06-28-2007, 10:08 PM
Bookmarks