I have a string as input, and I wanted to convert the entire string to lowercase, except for one random letter, which should be in uppercase.
I tried the following: splited is an array of input strings
word1 = splited[0].length();
word2 = splited[1].length();
word3 = splited[2].length();
int first = (int) Math.random() * word1;
String firstLetter = splited[0].substring((int) first, (int) first + 1);
String lowcase1 = splited[0].toLowerCase();
char[] c1 = lowcase1.toCharArray();
c1[first] = Character.toUpperCase(c1[first]);
String value = String.valueOf(c1);
System.out.println(value);
When I try to print a string, it ALWAYS returns the first letter as capital, and the rest of the string is lowercase. Why does this not return random letters other than the first letter.
Greetings
source
share