我必须检查beam_current值是否存在于索引1的9.5和10.5之间,然后是19.5和20.5之间的索引2,依此类推,直到21的beam_current索引和值应该介于209.5和210.5之间。为此我尝试了这个方式 -
int no=0;
List<Vacc_vs6> new_list=new ArrayList<Vacc_vs6>();
for(no=0;no<=21;no++)
{
String i= ref_jsp.get(no).getBeam_current();
**for()**//**how to now compare values of beam_current till index 21 and at respective index checking value between 9.95 to10.05,then on next inse 19.95 to 20.05 ans so on**?
}
What to write in this for loop?????
答案 0 :(得分:1)
请根据您的要求更改代码,但您可以使用此逻辑。
int no=0;
double i = 9.5;
List<Vacc_vs6> new_list=new ArrayList<Vacc_vs6>();
double j = 10.5;
for(no=0;no<=21;no++)// loop is same
{
double x;// take index from wherever you want
// assign value to x before use
if(x>i && x<j) // check that number between two ranges
{
//do your logic
}
else
{
new_list.add();// you pass Vacc_vs6 type value in argument of add method
}
i +=10;j +=10; // increment the ranges
}