Hello all,
Need help with a little assignment in java
assignment :
user inputs sentence, replaces all lowercase letters in string to uppercase, and vice versa.
ive created
for (int i = 0; i < s.length(); i++) {
if (Character.isUpperCase(s.charAt(i))) {
to DETECT if there is an uppercase letter found in the string 's', which is the input.nextLine();
Is there an easier way to do this? This is my approach: Loop looks through the string to find an upper case letter, replaces it with lower case, then outputs the string, but since i have to do both ways, do i have to add strings?
Ive tried to use the 'replaceall' function but im not having any luck, so many errors.
I know this is wrong, but this is what im trying to do:
for (int i = 0; i < s.length(); i++) {
if (Character.isUpperCase(s.charAt(i))) {
s.replaceAll(s.charAt(i), s.toLowerCase());
}
If anyone has suggestions or some completed code they can give me, that would be great.