September 2019
Intermediate to advanced
816 pages
18h 47m
English
Starting with JDK 8, we can obtain a quick description of a class (containing modifiers, name, types parameters, and so on) via the Class.toGenericString() method.
Let's take a look at several examples:
// public final class modern.challenge.Pair<L,R>System.out.println("Description of Pair: " + clazz.toGenericString());// public abstract interface java.lang.RunnableSystem.out.println("Description of Runnable: " + Runnable.class.toGenericString());// public abstract interface java.util.Map<K,V>System.out.println("Description of Map: " + Map.class.toGenericString());