简体   繁体   中英

how to use “where” in the List<int> like c# in android

I need to select multiple items. I need the numbers greater than 50. I do not know how to write this code. Sample C # code defines me what I need.Is this supported in Android?

    List<int> _numbers=new ArrayList<Integer>();
_numbers.add(111);
_numbers.add(54);
_numbers.add(25);
_numbers.add(552);
_numbers.add(58);

// like c# code : _numbers.where(d=>d>=50);

Iterate though your list and put the values greater than 50 into another list. You can get the integers greater than 50 with an if-clausel:

 List<int> xxxx = new ArrayList<Integer> for(int value : _numbers){ if(value > 50) xxxx.add(value ) } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM