2 回答
TA贡献1836条经验 获得超4个赞
在 package1 中创建一个 POJO 类来保存您的输入/输出值,例如:
class Data {
public String s;
public int a1;
public int a1;
}
那么您可以更改以下签名:
public List<Object> returnvalue (String aString, int aInt, int bInt)
到
public Data returnValue(Data aData)
更新
假设 package1 中有 2 个类
Data.java:
package package1;
public class Data {
public String s;
public int a1;
public int a2;
}
和Solution.java:
package package1;
public class Solution {
public Data returnValue(Data input) {
Data data = new Data();
data.s = input.s + "append";
data.a1 = input.a1 + 1;
data.a2 = input.a2 + 2;
return data;
}
}
您可以在 packate2 中使用它们,如下App.java:
package package2;
import package1.Data;
import package1.Solution;
public class App {
public static void main(String[] args) throws Exception {
Data input = new Data();
input.s = "ipsum";
input.a1 = 1;
input.a2 = 2;
Solution solution = new Solution();
Data result = solution.returnValue(input);
// use result
}
}
添加回答
举报