Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. //Metodo que permite contar los espacios de la cadena almacenada en la variable
  2. public void espacios(){
  3. int cont=0;
  4. this.A = XX.toCharArray();
  5. int aux=0;
  6. for (int h=0;h<A.length;h++){
  7. if( A[h] == ' '){
  8. aux = A[h];
  9. cont=cont+1;
  10. }else{
  11. aux = aux;
  12. cont = cont;
  13. }
  14. }
  15. if(cont==0){
  16. System.out.println("No hay espacios.");
  17. }else{
  18. System.out.println(cont +" --> Son los espacios de la frase, en las posiciones "+aux);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement