⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 test.java

📁 学了2个月java 练习用~ 可以看下 希望同意
💻 JAVA
字号:
import java.lang.reflect.*;

public class  test
{
	public static void main(String[] args) throws Exception
	{
		EmployeeRef a=new EmployeeRef("kevin","male",30);
		Class now=a.getClass();
		Field[] nowfield=now.getDeclaredFields();
		for (int i=0;i<nowfield.length ;i++ ){
			if("name".equals((nowfield[i]).getName())){
				nowfield[i].setAccessible(true);
				nowfield[i].set(a,"hello");
				System.out.println(nowfield[i].get(a));
			}
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -