java存储方法值并验证该值是否为真
假设我在Netbeans中有两个项目Pro1'&;'Pro2'
我需要在Pro2
中调用一个方法,它是public int method1
到Pro1
。由于我在Pro1
中调用了method1
,所以我需要将method1
的值存储在一个变量storeMethod1
中,因此我需要检查存储的值是否正确
那我该怎么做呢?Pro1
的代码示例正确吗
编辑:项目已添加到库中。除了if声明,一切都正常
Pro2代码示例:
public int method1(String a, String b, boolean c, String d, int e) {
// basically, here will just create a function (eg: addUser/User registration)
}
Pro1代码示例:
public class Pro1 {
...
public Response method1() {
// intialize the variables
//call the method in Pro2
Pro2 pro2 = new Pro2();
int storeMethod1 = pro2.method1(a, b, c, d, e);
//return the storeMethod1 if able to call method1
if (storeMethod1 == pro2.toString(method1)) {
returnData.put("message" , "Success");
} else {
returnData.put("message", "Invalid Input");
}
return Response.ok (gson.toJson(returnData), MediaType.APPLICATION_JSON).build();
}
}
提前谢谢
# 1 楼答案
您需要将“项目2”添加到“项目1”库中
要在netbeans中实现这一点: