ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

Can we access the private method from outside the class?

user-image
تم إضافة السؤال من قبل Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
تاريخ النشر: 2014/04/16
Abdullah Abdurrahman
من قبل Abdullah Abdurrahman , Software Development Manager , Global Computer Services

According to object oriented rules, NO.

Prasanna Kumar S R
من قبل Prasanna Kumar S R , Cyber Security Manager , MetLife

No not possible. Private modifiers are meant to be accessed only within that class.

yahia dekar
من قبل yahia dekar , ingenieur d'etat en informatique , universite djilali liabbes - sidi bel abbes

no here we talks about a levet of security

about your question no

Mufeed Farhan
من قبل Mufeed Farhan , HR Applications Manager , SBM

 

use setAccessible(true) on your Method object before using its invoke method for Java

and for C# and .net your can use the concept of friend or  System.Reflection class with InvokeMember .

 

This is good example on Java :

http://stackoverflow.com/questions//how-to-call-a-private-method-from-outside-a-java-class

 

I hope this info. is helpful to you .

  

المزيد من الأسئلة المماثلة