是的,如果 OBJECT_1,OBJECT_2,OBJECT_3 有不同的类型,那么......你可以这样做......
public class Object {
// here we are creating a class who has all objects you want to return,
// this is called wrapper class
private Object_1 object_1;
private Object_2 object_1;
private Object_3 object_1;
public Object_1 getObject_1() {
return object_1;
}
public void setObject_1(Object_1 object_1) {
this.object_1 = object_1;
}
public Object_2 getObject_1() {
return object_1;
}
public void setObject_1(Object_2 object_1) {
this.object_1 = object_1;
}
public Object_3 getObject_1() {
return object_1;
}
public void setObject_1(Object_3 object_1) {
this.object_1 = object_1;
}
}
public class Test{
public Object execute(int servicecode)
{
Object object = new Object();
switch (servicecode)
{
case 1:
return object.setObject_1(object_1);
case 2:
return object.setObject_2(object_2);;
case 3:
return object.setObject_3(object_3);;
}
}
}