SHARE
TWEET

Untitled

a guest Jun 16th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static boolean esVocal(char c) {
  2.     return "AEIOUaeiou".indexOf(c) != -1;
  3. }
  4. public String ordenarvocales(String cadena) {
  5.     if (cadena == null) {
  6.         return cadena;
  7.     }
  8.     StringBuilder result = new StringBuilder(cadena);
  9.  
  10.  
  11.     ArrayList<Integer> PosicionVocales = new ArrayList<>();
  12.  
  13.     ArrayList<Character> vocales = new ArrayList<>();
  14.     for (int pvocal = 0; pvocal< cadena.length(); pvocal++) {
  15.         char vocalActual = cadena.charAt(pvocal);
  16.         if(esVocal(vocalActual)) {
  17.             PosicionVocales.add(pvocal);
  18.             vocales.add(vocalActual);
  19.         }
  20.     }
  21.  
  22.     Collections.sort(vocales);
  23.  
  24.     for(Integer PosicionVocal : PosicionVocales) {
  25.         char vocal = vocales.remove(0);
  26.         result.setCharAt(PosicionVocal , vocal);
  27.     }
  28.     return result.toString();
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top