Java reflect Flashcards

1
Q

What is reflect

A

In computer science, reflection is the ability of a process to examine, introspect, and modify its own structure and behavior. Reflection is an API that is used to examine or modify the behavior of methods, classes, interfaces at runtime. The required classes for reflection are provided under java.lang.reflect package. Reflection gives us information about the class to which an object belongs and also the methods of that class which can be executed by using the object. Through reflection, we can invoke methods at runtime irrespective of the access specifier used with them.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Java Reflect core classes

A
  1. Class
  2. Constructor
  3. Method
  4. Field
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Class类

A

Class type’s object is the description of other classes: structure, ‘class and interface’;

through the object we can get the class’s constructor, member method and fields.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Class类 core method

A

method usage

Class.forName() 静态方法,get class objection

classObj.newInstance() 用默认构造函数,创建对象

classObj.newConstructor() 获得构造函数对象

classObj.newMethod() 获得method对象

classObj.newField() 获得field对象

How well did you know this?
1
Not at all
2
3
4
5
Perfectly