fork(3) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int[] groupMin = new int[]{0, 10, 20};
  13. int[] groupMax = new int[]{10, 20, 9999};
  14.  
  15. int[] ages = new int[]{ 1, 2, 3, 10, 12, 76, 56, 89 };
  16.  
  17. int targetGroup = 1;
  18. int count = 0;
  19. for( int age : ages ){
  20. if( age >= groupMin[targetGroup] && age < groupMax[targetGroup] ){
  21. count++;
  22. }
  23. }
  24.  
  25. System.out.println("Group " + targetGroup + " range is " +
  26. groupMin[targetGroup] + " - " + groupMax[targetGroup]);
  27. System.out.println("Count: " + count);
  28. }
  29. }
Success #stdin #stdout 0.07s 380224KB
stdin
Standard input is empty
stdout
Group 1 range is 10 - 20
Count: 2