/*
in order to call private method of class outside of that class
*
* you must have to declare one public method in that class
* and from that public method we can call private method of class
*
* in short
* class's public method can access class's private method
*/
class MyClass1 {
private void show() {
System.out.println("This is private function can not called outside of class");
}
public void call() {
show();
}
}
class PrivateExample {
public static void main(String args[]) {
MyClass1 c = new MyClass1();
c.call();
}
}
in order to call private method of class outside of that class
*
* you must have to declare one public method in that class
* and from that public method we can call private method of class
*
* in short
* class's public method can access class's private method
*/
class MyClass1 {
private void show() {
System.out.println("This is private function can not called outside of class");
}
public void call() {
show();
}
}
class PrivateExample {
public static void main(String args[]) {
MyClass1 c = new MyClass1();
c.call();
}
}
0 comments:
Post a Comment