我估計 樓主想説這個
用 Bean 或者 HashMap 都可以吧?
// This is a bad Method since you need to change the method declaration
// everytime if you wanna add some other parameters to this method.
public void doSomething(int id, String name, int age, Date birthday) {
return null;
}
// This is a better Method
public void doSomething(User user) {
int id = user.getId();
String userName = user.getName();
return null;
}
// If you don't want to create bean for some reason
// you may try using HashMap, surely this also has some draw backs.
public void doSomething(HashMap<String,Object> parms) {
Integer id = (Integer)parms.get("userId");
String userName = (String)parms.get("userName");
return null;
}