fork 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[] vowelCodePoints = "aeiouy".codePoints().sorted().toArray();
  13.  
  14. int[] codePoints = "testy".codePoints().toArray();
  15. List < Integer > indicesOfVowels = new ArrayList <>( codePoints.length );
  16. for ( int index = 0 ; index < codePoints.length ; index++ )
  17. {
  18. int position = Arrays.binarySearch( vowelCodePoints , codePoints[ index ] );
  19. if ( position >= 0 )
  20. {
  21. String vowel = Character.toString( codePoints[ index ] );
  22. System.out.println( "Vowel: " + vowel + " | Index: " + index );
  23. }
  24. }
  25. }
  26. }
Success #stdin #stdout 0.14s 52736KB
stdin
Standard input is empty
stdout
Vowel: e | Index: 1
Vowel: y | Index: 4