OO Programming with Java


Listing operations with introspection

All the classes are objects (also called 'instances') from Class that can be used to get info about operations:

try {
  Class c = Class.forName("java.lang.String");
  for(Method m : c.getDeclaredMethods())
    System.out.println(m.getName());
} catch (Exception e) {
  e.printStackTrace();
}

The try_catch statement serves to manage errors/exceptions (e.g. a class does not exist).