Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
It is all in java.
So its like I have a java class 'test' with the main method. It makes a variable which is an instance of another class. In its constructer it calls another public method say 'method1'. So in method1 I want to get the name of the class calling it.
It gives me the test class with main method. Than i got the method caller and it was main. But I want the class whose constructor is used. I need this to prevent any other class starting from any point to not have access to this method

What I have tried:

I can't think what to do. I was just stuck what to do
Posted
Updated 18-Aug-19 21:31pm

1 solution

You did not provide the code you use, so we can not say what's wrong with it... Nevertheless...
Please, read these:
Java - Inner classes[^]
Java - Inheritance[^]
Java - Overriding[^]
Java - Polymorphism[^]

I hope you'll find something useful to you...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900