convert the alternate characters of the string to upper case . The first letter of the string has to be Capital

后端 未结 2 836
情话喂你
情话喂你 2021-01-29 16:07

WAP to convert the alternate characters of the string to upper case . The first letter of the string has to be Capital. I/P:We are the worlD O/P: We ArE tHe WoRlD

2条回答
  •  有刺的猬
    2021-01-29 16:56

    Since the first letter is upper case, we conclude that every letter of the string at even position will be made to upper case, but since there may be spece or special characters we will have to keep that in mind also. A sample algorithm you can use is:

    String x = jTextField1.getText();
    len = x.length();
    String otherstring;
    int j=0; //to be used as counter to check alternate char
    for (int i = 0;i

    the characters are appended to the other string and you can display the output.

提交回复
热议问题