0
private method call from outside class
guys any body know how to call a private method from outside class....???
3 Answers
+ 2
You can't. It's private. Switch it to public. (Alternatively, you can define in the class a public method that will call the private method for you, but that's a bit dumb.)
0
You can not do it
0
yes, you can call a private method indirectly but not directly. Try calling it through another public method in the same class or try calling through constructor
ex:
Program() // let ur class name be program
{ // call ur private method here..
add(); // let add is ur private method
}
or
if have any other public method in the same class example sub();
public int sub()
{ add(); // call private method here..
......;
........; // remaining statements of sub method
}