我在模型中有多个函数返回Object [] []数组。我需要使用bean但不知道应用哪种策略。所有这些数组都返回不同的数据。我应该这样做吗?
public class VoiceMessagesBean
{
Object[][] inbox_messages;
Object[][] accepted_messages;
Object[][] rejected_messages;
Object[][] response_yes;
Object[][] response_no;
Object[][] feedback_messages;
Object[][] processed_messages;
Object[][] saved_messages;
public Object[][] getInbox_Messages()
{
return inbox_messages;
}
public void setInbox_Messages(Object[][] inbox_messages)
{
this.inbox_messages=inbox_messages;
}
public Object[][] getAccepted_Messages()
{
return accepted_messages;
}
public void setAccepted_Messages(Object[][] accepted_messages)
{
this.accepted_messages=accepted_messages;
}
public Object[][] getRejected_Messages()
{
return rejected_messages;
}
public void setRejected_Messages(Object[][] rejected_messages)
{
this.rejected_messages=rejected_messages;
}
public Object[][] getResponse_Yes()
{
return response_yes;
}
public void setResponse_Yes(Object[][] response_yes)
{
this.response_yes=response_yes;
}
public Object[][] getResponse_No()
{
return response_no;
}
public void setResponse_No(Object[][] response_no)
{
this.response_no=response_no;
}
public Object[][] getFeedback_Messages()
{
return feedback_messages;
}
public void setFeedback_Messages(Object[][] feedback_messages)
{
this.feedback_messages=feedback_messages;
}
public Object[][] getProcessed_Messages()
{
return processed_messages;
}
public void setProcessed_Messages(Object[][] processed_messages)
{
this.processed_messages=processed_messages;
}
public Object[][] getSaved_Messages()
{
return saved_messages;
}
public void setSaved_Messages(Object[][] saved_messages)
{
this.saved_messages=saved_messages;
}
}
或者我应该在控制器中创建bean的多个实例,并在bean中创建一个Object Array,如下所示,并在每次调用函数时使用单个object [] []数组。但后来我需要多次实例化bean对象。
public class MemberBean {
Object [][] memberObject;
public Object[][] getMemberObject() {
return memberObject;
}
有什么更好的方法?
答案 0 :(得分:-1)
最好你应该使用类的实例bcoz类的主要动机是减少变量的出现并更好地使用它的实例。