fork(5) download
  1. import java.util.*;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. int[] a = {1, 3, 3, 4, 1, 4, 4, 4, 4};
  6. int n = a.length;
  7.  
  8. Scanner scanner = new Scanner(System.in);
  9. int q = scanner.nextInt();
  10.  
  11. for (int l = 0; l < q; l++) {
  12. int qry = scanner.nextInt();
  13. int frq = 0;
  14.  
  15. for (int j = 0; j < n; j++) {
  16. if (a[j] == qry) {
  17. frq++;
  18. }
  19. }
  20.  
  21. System.out.print(qry + " -> number occurs ");
  22. System.out.print(frq + " ");
  23. System.out.println("-> times in the array given");
  24. }
  25. }
  26. }
  27.  
Runtime error #stdin #stdout #stderr 0.13s 47392KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.util.NoSuchElementException
	at java.base/java.util.Scanner.throwFor(Scanner.java:937)
	at java.base/java.util.Scanner.next(Scanner.java:1594)
	at java.base/java.util.Scanner.nextInt(Scanner.java:2258)
	at java.base/java.util.Scanner.nextInt(Scanner.java:2212)
	at Main.main(Main.java:9)