📄 demoapplication.java
字号:
package dev.easyref.tester;
import dev.easyref.util.*;
/**
* <p>Title: Easy Reflection</p>
* <p>Description: This project demonstrate the easier usage of Reflection</p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: N/A</p>
* @author Doron Barak
* @version 1.0
*/
public class DemoApplication {
public static void main(String[] args) {
// Create an Arguments object..
Arguments xArgs = new Arguments();
// Fill the Arguments object with data..
xArgs.addElement("Doron");
xArgs.addElement("Barak");
xArgs.addElement(36);
xArgs.addElement(3000.0f);
// Create an instance of an Employee class based on the data..
Object o = xArgs.getInstance("dev.easyref.data.Employee");
// Show the object that we received..
System.out.println("Created instance >> " + o);
// Create a new Arguments object, collecting the data in the object..
xArgs = new Arguments(o);
// Display the collected data..
System.out.println("Instace data >> " + xArgs);
// Change the first stored value to 1000..
xArgs.setElementAt(1000.0f, 1);
// Order the Arguments object to not print Excpetion stacks..
xArgs.hideExceptions();
// Invoke the updateSalary() method of the Employee instance..
xArgs.runMethod(o, "updateSalary");
// Check to see if we had an Excpetion..
if (xArgs.hadMethodError()) {
// Remove unwanted values from the Arguments object..
xArgs.removeElementAt(0);
xArgs.removeElementAt(1);
xArgs.removeElementAt(1);
// Now, we try to invoke updateSalary() again..
xArgs.runMethod(o, "updateSalary");
}
// Display object after Salary raise..
System.out.println("After Salary Raise >> " + o);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -