public ListFloat listFloat= new ArrayList;判断集合中的数据是否大于180或者小于-180 判断是否80以上的数据大于180或者小于180是的话返回false否则返回为true 给出具体代码
以下是给出的具体代码实现:
public boolean checkFloatList(List<Float> list) {
int count = 0;
for (Float num : list) {
if (num > 180 || num < -180) {
return false;
}
if (num > 180 || num < -180) {
count++;
}
}
return (count / (float)list.size()) < 0.8;
}
使用该方法可以判断集合中的数据是否大于180或小于-180,以及判断80%以上的数据是否大于180或小于-180。如果有数据大于180或小于-180,则返回false,否则返回true。
原文地址: https://www.cveoy.top/t/topic/iYrd 著作权归作者所有。请勿转载和采集!