![]() |
VOOZH | about |
The getName() method of the Thread class is used to retrieve the name of a thread. It helps in identifying threads during execution, especially useful for debugging and logging in multithreaded applications.
Thread name: Thread-0
Explanation: The getName() method fetches and prints the name of the thread. If no custom name is set, it displays the default thread name.
public final String getName()
Example: Program to check whether class contains a certain specific method.
Class Object Contains Method whose name is method1
Explanation: Above program uses Java Reflection (Class and Method) to retrieve all methods of a class at runtime. It then checks whether a method with the name "method1" exists and prints a message if found.