Click here to watch in Youtube :
https://www.youtube.com/watch?v=EJsXlMlOoNk&list=UUhwKlOVR041tngjerWxVccw
Click the below Image to Enlarge
Java Tutorial : Java Class Literals |
public class ClassLiteralDemo { public static void main(String[] args) { try { Class<?> stringClassObject = Class.forName("java.lang.String"); System.out.println("Get stringClassObject using 'Class.forName' method: " + stringClassObject); } catch (ClassNotFoundException e) { e.printStackTrace(); } Class<?> stringClassObject = java.lang.String.class; System.out.println("Get stringClassObject using 'class Literal' : " + stringClassObject); Class<?> longClassObject = java.lang.Long.class; System.out.println("Get longClassObject using 'class Literal' : " + longClassObject); } }
Get stringClassObject using 'Class.forName' method: class java.lang.String Get stringClassObject using 'class Literal' : class java.lang.String Get longClassObject using 'class Literal' : class java.lang.Long
https://sites.google.com/site/javaee4321/java/VariableDemoClassLiteralsApp.zip?attredirects=0&d=1
See also:
No comments:
Post a Comment