Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.lang.reflect.Constructor;
- import java.lang.reflect.Field;
- import java.lang.reflect.Method;
- public class Test {
- public static void main(String[] args) {
- try {
- Class cl = Class.forName("java.lang.String");
- Constructor cnst[] = cl.getConstructors();
- Field fld[] = cl.getDeclaredFields();
- Method mtd[] = cl.getMethods();
- System.out.println("Name of the Constructors of the String class");
- for (int i = 0; i < cnst.length; i++) {
- System.out.println(cnst[i].getName());
- }
- System.out.println("Name of the Declared fields");
- for (int i = 0; i < fld.length; i++) {
- System.out.println(fld[i].getName());
- }
- System.out.println("Name of the Methods");
- for (int i = 0; i < mtd.length; i++) {
- System.out.println(mtd[i].getName());
- }
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement