Monday, 5 October 2015

Java Tutorial : Java Class Literals


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
ClassLiteralDemo.java
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);

    }
}
Output
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

To Download VariableDemoClassLiteralsApp Project Click the below link
https://sites.google.com/site/javaee4321/java/VariableDemoClassLiteralsApp.zip?attredirects=0&d=1

See also:
  • All JavaEE Viedos Playlist
  • All JavaEE Viedos
  • All JAVA EE Links
  • Servlets Tutorial
  • All Design Patterns Links
  • JDBC Tutorial
  • Java Collection Framework Tutorial
  • JAVA Tutorial
  • No comments:

    Post a Comment

    Google+ Followers

    Google+ Badge