Wednesday, 3 February 2016

Java Tutorial : Java Object Class(getClass method)


Click here to watch in Youtube : 
https://www.youtube.com/watch?v=xaaUTIlmrhM&list=UUhwKlOVR041tngjerWxVccw

Employee.java
public class Employee
{
    private String name;
}
ObjectClassTest.java
import java.util.ArrayList;
import java.util.HashSet;

public class ObjectClassTest
{

    public static void main(String[] args)
    {
        Employee employeeObj = new Employee();

        /*
         * Returns the Class object that represents the
         * runtime class of this object.
         */

        System.out.println("employeeObj.getClass() = "
                + employeeObj.getClass());

        ArrayList<String> arrayListObj = new ArrayList<String>();

        System.out.println("arrayListObj.getClass() = "
                + arrayListObj.getClass());

        HashSet<String> hashSetObj = new HashSet<String>();

        System.out.println("hashSetObj.getClass() = "
                + hashSetObj.getClass());

    }

}
Output
employeeObj.getClass() = class Employee
arrayListObj.getClass() = class java.util.ArrayList
hashSetObj.getClass() = class java.util.HashSet
Click the below link to download the code:
https://sites.google.com/site/javaee4321/java/ObjectClassDemo_getClass_App.zip?attredirects=0&d=1

Github Link:
https://github.com/ramram43210/Java/tree/master/BasicJava/ObjectClassDemo_getClass_App

Bitbucket Link:
https://bitbucket.org/ramram43210/java/src/8fa82bcbf36a8ef675302adced6f7a0764627bd4/BasicJava/ObjectClassDemo_getClass_App/?at=master

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