0
A string
Hello, please i would like to know if with the word toto as an example wrote by a user, why do i have on my screen : ToTo? here is my java code: import java.util.*; public class Mot { public static void main(String[] args) { System.out.println("Write a string :"); Scanner s = new Scanner(System.in); String word = s.nextLine(); char c = word.charAt(0); for(int p = 0; p < word.length(); p++) { if(c >= 'a' && c <= 'z') { c -= 'a' - 'A'; char nvchar = (char)c; System.out.println("You have written : " + word.replace(word.charAt(0), nvchar)); } } } }
1 Answer