Mega Code Archive

 
Categories / Java Tutorial / Reflection
 

List methods of a class using Reflection

import java.lang.reflect.Method; public class Main {   public static void main(String[] args) {     Class aClass = String.class;     // Get the methods     Method[] methods = aClass.getDeclaredMethods();     // Loop through the methods and print out their names     for (Method method : methods) {       System.out.println(method.getName());     }   } } /* hashCode compareTo indexOf equals toString charAt checkBounds codePointAt codePointBefore codePointCount compareToIgnoreCase concat contains contentEquals copyValueOf endsWith equalsIgnoreCase format getBytes getChars intern isEmpty lastIndexOf length matches offsetByCodePoints regionMatches replace replaceAll replaceFirst split startsWith subSequence substring toCharArray toLowerCase toUpperCase trim valueOf */