My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package com.lineadecodigo.java.string;

/**
* @file MayusculasDespuesDePunto.java
* @version 1.0
* @author Linea de Codigo (http://lineadecodigo.com)
* @date 24.septiembre.09
* @url http://lineadecodigo.com/java/poner-en-mayusculas-despues-de-punto/
* @description Convertir a mayúsculas todo carácter que encontremos después de un punto.
*/



public class MayusculasDespuesDePunto {

public static void main(String[] args) {
// TODO Auto-generated method stub

String frase = "hola juan.me ha gustado mucho.hagámonos público.mañana hablamos.luis";
String frase2 = "";
int indice = 0;
int indicepunto = 0;


indicepunto = frase.indexOf('.',indice);

while (indicepunto >=0) {
// El primer carácter es en mayúsculas
frase2 = frase2 + frase.substring(indice,indice+1).toUpperCase();
// Pegamos el resto hasta el primer punto
frase2 = frase2 + frase.substring(indice+1,indicepunto+1);

indice = indicepunto + 1;
indicepunto = frase.indexOf('.',indice);
}

// Incluimos el final de la frase
frase2 = frase2 + frase.substring(indice,indice+1).toUpperCase();
frase2 = frase2 + frase.substring(indice+1,frase.length());


System.out.println(frase2);

}

}

Change log

r186 by vcuervo on Sep 24, 2009   Diff
Poner en mayúsculas los caracteres después
de punto.
Go to: 
Project members, sign in to write a code review

Older revisions

All revisions of this file

File info

Size: 1279 bytes, 46 lines
Powered by Google Project Hosting