Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
The license selected for the repository is subject to the license used by the main branch of the repository.
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
java_notes
/
com
/
test02
/
ReflectDemo7.java
java_notes
/
com
/
test02
/
ReflectDemo7.java
ReflectDemo7.java 1.86 KB
Copy Edit Raw Blame History
losidk authored 2021年04月25日 22:20 +08:00 . feature: 反射获取类的成员方法并调用
package com.test02;
import java.lang.reflect.Method;
public class ReflectDemo7 {
// 通过反射获取类的成员方法
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InstantiationException {
Class<?> c = Class.forName("com.test01.Student");
// Method[] getMethods 返回一个包含方法对象的数组, 方法对象反映由该Class 对象表示的类或接口的所有公共方法,包括由类或接口声明的对象以及从超类 和超级接口继承的类
// Method[] getDeclaredMethods () 返回一个包含方法对象的数组,方法对象反映由 Class 对象表示的类或接口的所有声明方法,包括 public, protected, default(package)访问 和私有方法,但不包括继承方法
Method[] methods = c.getMethods();
for (Method method : methods) {
System.out.println(method);
// public java.lang.String com.test01.Student.toString()
// public void com.test01.Student.method1()
// public void com.test01.Student.method2(java.lang.String)
// public java.lang.String com.test01.Student.method3(java.lang.String,int)
// public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
// public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
// public final void java.lang.Object.wait() throws java.lang.InterruptedException
// public boolean java.lang.Object.equals(java.lang.Object)
// public native int java.lang.Object.hashCode()
// public final native java.lang.Class java.lang.Object.getClass()
// public final native void java.lang.Object.notify()
// public final native void java.lang.Object.notifyAll()
}
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

Releases

No release

Contributors

All

Language(Optional)

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/losidk/java_notes.git
git@gitee.com:losidk/java_notes.git
losidk
java_notes
java_notes
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /