泛型类的类型我有一个名为如何通过在Java
ParameterList<Recipient_Type,Subject_Type> {
//some code here...
}
预先定义的类,它是通用采取收件人型和主题型。我有一个对象调用对应这已经得到了setter方法来设置不同类型的收件人像
correspondence.setRecipient1((Recipient1)recipient),
correspondence.setRecipient2((Recipient2)recipient),
correspondence.setRecipient3((Recipeint3)recipient).
所以基本上设置不同类型的科目,如
correspondence.setSubject1((Subject1)subject)
correspondence.setSubject2((Subject2)subject).
和类似的方法我有2种不同的主题类型和3种不同类型的收件人。直到这部分代码我不能改变任何东西,因为它的一些现有的框架代码。
现在我有一个下面的方法,它将我的通信对象作为参数,并需要实例化ParameterList类,传递正确的主题和收件人类型。通信对象上只能设置一个主题和收件人。所以在下面的方法
public void doTheJob(Correspondence correspondence){
//How do I instantiate the ParameterList class provided subject can be any one of the two
//and recipient can be any one of the three.
}
我希望看到您的代码而不是阅读它的说明;) – Bozho
是我现在看起来好多了的问题陈述... – user977263