0

private method call from outside class

guys any body know how to call a private method from outside class....???

10th Sep 2016, 10:47 AM
Rishi Thakur
Rishi Thakur - avatar
3 Réponses
+ 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.)
10th Sep 2016, 10:56 AM
Zen
Zen - avatar
0
You can not do it
10th Sep 2016, 12:10 PM
נוי בן חיים
נוי בן חיים - avatar
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 }
13th Sep 2016, 5:36 PM
Teja Naraharisetti
Teja Naraharisetti - avatar