java 反射错误

[color=red]实体类:[/color]
public class Hotel {

private long id;

public long getId() {
    return id;
}

public void setId(long id) {
    this.id = id;
}

}

[color=red]测试方法:[/color]
public void testReflect() throws Exception{
Object object = Hotel.class.newInstance();
String setMethod = "setId";
Method method = object.getClass().getDeclaredMethod(setMethod, new Class[]{Object.class});
method.invoke(object, new Object[]{1L});
}

[color=red]出错信息:[/color]
java.lang.NoSuchMethodException: setId
at java.lang.ClassCache.findMethodByName(ClassCache.java:247)
at java.lang.Class.getDeclaredMethod(Class.java:731)
at java.lang.reflect.Method.invokeNative(Native Method)

Method method = object.getClass().getDeclaredMethod(setMethod, new Class[]{[color=red]long.class[/color]});

public void testReflect() throws Exception{
Object object = Hotel.class.newInstance();
String setMethod = "setId";
Method method = object.getClass().getMethod(setMethod);
method.invoke(object, new Object[]{1L});
}

public static void main(String[] args) throws Exception{
Object o = Hotel.class.newInstance();
String setMethod = "setId";
Method[] methods = o.getClass().getMethods();
for(int i=0;i<methods.length;i++){
Method m = methods[i];
// System.out.println(m.getName());
if(m.getName().equals("setId")){
System.out.println("1111");
m.invoke(o, new Object[]{1L});
}

    }
    //method.invoke(o, new Object[]{1L});
}

亲,其实这样写就可以了!
Method method = Hotel.class.getMethod("setId",long.class);