如何在android for循环中找到方法 [英] How to find when method finished in android for loop
本文介绍了如何在android for循环中找到方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道何时在Java中for循环完成方法
i want to find to know when method finished in for loop in Java
例如:
for(int i = 0; i< list.size();i++){
Client.check(list.get(i).getUsername);
}
我想检测并找到Client.check上次运行并循环完成:)
i want to detect and find Client.check last run and loop finish :)
推荐答案
有两种方法可以做到这一点,在for循环的内部和外部。
There are two ways to do this, inside and outside of for loop.
Inside for循环。
Inside for loop.
for(int i = 0; i < list.size(); i++) {
Client.check(list.get(i).getUsername);
if(i == (list.size()-1)){
//this is the last iteration of for loop
}
}
外部循环。
for(int i = 0; i < list.size(); i++) {
Client.check(list.get(i).getUsername);
}
Log.d(TAG, "For loop finished);
这篇关于如何在android for循环中找到方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文