gpt4 book ai didi

java - 方法内的方法

转载 作者:行者123 更新时间:2023-12-01 22:31:52 25 4
gpt4 key购买 nike

我写了下面的代码

List<UserDetails> getUserList(String Json){         
try {
JSONObject jsonObject = new JSONObject(Json);
int myname = jsonObject.getInt("itemsPerPage");
System.out.println(myname);

JSONArray jsonarray = (JSONArray) jsonObject.get("list");
System.out.println(jsonarray.length());

if(null != jsonarray && jsonarray.length() == 25){
RestClient restClient = new RestClient();
URL= someurl;
checkValue="USERDETAILS";
startIndex += 25;
String jsonResult = restClient.postJiveUsersData(URL,restUserName,restPassword);
if(null != jsonResult) {
getUserList(jsonResult);
}
}
System.out.println("User List size::" +userDetailsList.size());
return userDetailsList;
<小时/>

执行上述操作后,“用户列表大小”会打印多次。请问原因,有什么办法可以避免多次打印。

感谢您提前提供帮助。

问候纳拉辛哈·雷迪 P

最佳答案

它会打印多次,因为您的 getUserList 方法正在调用自身,因此 System.out.println("User List size::"+userDetailsList.size()); 被执行多次。

关于java - 方法内的方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27599943/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com