Reputation: 354
Hello I have class with private method, and I need override it by reflation. I see many examples fro change private fields, or call private methods, but I don't found any override example.
I have this code
public class TestClass {
public void print(string str)
{
doSomeThing(str);
}
private void doSomeThing(string str)
{
Log.d("tag","printed :"+str);
}
}
but I want change Log.d("tag","printed :"+str);
to Log.d("tag","printed override :"+str);
or other code.
How is it possible do with reflection?
Upvotes: 0
Views: 225
Reputation: 358
You cannot override a private member, because a private member belongs to its unique class. If another class extends that class, the new class would not have such member, and therefore you can just create a new one.
Maybe you want to use the protected modifier instead of private?
Upvotes: 0