w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
I want to check the whitespace of a string and want to print the first character just after the whitespace to a upper case letter

You are almost there, but you need to store the new uppercase character back into your array:

    String str = "I am in trouble";
    char[] arr = str.toCharArray();
    for (int i = 0; i < arr.length; i++) {
        if (arr[i] == ' ') {
            char c = arr[i + 1];
            arr[i+1] = Character.toUpperCase(c); // like this;

© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.