Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Metodo que permite contar los espacios de la cadena almacenada en la variable
- public void espacios(){
- int cont=0;
- this.A = XX.toCharArray();
- int aux=0;
- for (int h=0;h<A.length;h++){
- if( A[h] == ' '){
- aux = A[h];
- cont=cont+1;
- }else{
- aux = aux;
- cont = cont;
- }
- }
- if(cont==0){
- System.out.println("No hay espacios.");
- }else{
- System.out.println(cont +" --> Son los espacios de la frase, en las posiciones "+aux);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement