Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- public class Main {
- public static void main(String[] args) {
- int numbers [] = new int[]{2, 5, 8, 9, 2, 3, 2, 9, 6, 5, 5, 5, 9, 8};
- List<Integer> listOfNumbers = new ArrayList<Integer>();
- for(int number:numbers) {
- listOfNumbers.add(number);
- }
- int frequency = Collections.frequency(listOfNumbers, 5);
- System.out.println("The frequency of 5 is " + frequency);
- }
- }
Add Comment
Please, Sign In to add comment