
Are you confused about what Class Class In Java is? Don’t worry we are here to help you.
Reading this article will help you to get a clear insight into what class class in Java is, clearing all your doubts and helping you in your journey of becoming an Android Developer.
| S.NO. | Methods | Why is it used |
| 1 | asSubclass(Class < U> clazz) | This method is used in Java to safely cast a class reference to a subclass reference at runtime, It mainly ensures that the casting is done safely. |
| 2 | getName() | This method is used for Returning the fully qualified name of the class. |
| 3 | getSimpleName() | This method is used to return the simple name of the class that is without the package name. |
| 4 | isInterface() | This method in Java is basically used for checking if the class is an interface or not. |
| 5 | isArray() | It is used for checking if the class represents an array type or not. |
| 6 | isPrimitive() | This method in Java is used to check if the class represents a primitive type or not. |
| 7 | getPackage() | This method is used to return the package of the class. |
| 8 | getSuperclass() | getSuperclass() method in Java is used to return the superclass of the class. |
| 9 | getInterfaces() | This method in Java.lang.class returns an array of interfaces that are implemented by the class. |
| 10 | getDeclaredFields() | This method in Java.lang.class is used to return an array of fields declared by the class. |
| 11 | getDeclaredAnnotation(Class < A> annClass) | This method is used to return the present element’s annotation if it is present, else this method returns a null value. |
| 12 | isAssignableFrom(Class<?> cls) | It is used to check if the class represented by the object can be assigned from the specified class. |
| 13 | getAnnotation(Class<A> annotationClass): | This method in Java Class Class is used to return the annotation associated with the class, if present. |
| 14 | getComponentType() | This method of Java Class Class is used to return the class that represents the component type of an array. If there is no component present it will declare null value. |