In this example we will find the name of the class name.
Description of the method used in the example:
getStackTrace: Provides programmatic access to the stack trace information printed by printStackTrace(). It returns array of StackTraceElement objects.
getClassName: It returns String type fully qualified name of the class containing the execution point represented by this stack trace element.
Here is the video tutorial of "How to get the name of the calling class in Java?":
Here is the code of GetCollingClass.java
Output will be displayed as:
Rs. 20,000 US$ 300
Today: Rs. 10,000 US$150
Course Duration: 30 hrs
Posted on: October 23, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles