我写了下面的代码
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;执行上述操作后,“用户列表大小”将打印不止一次。请允许我知道原因,是否有任何方法可以避免冗长的时间打印它。
谢谢你提前帮忙。
向Narasimha Reddy P问好
发布于 2014-12-22 09:38:02
它打印不止一次,因为您的getUserList方法正在调用自己,因此System.out.println("User List size::" +userDetailsList.size());被多次执行。
https://stackoverflow.com/questions/27599943
复制相似问题