Java small white online for
CodePudding user response:
Just a minute or two, also
import java.util.Scanner;
Public class CaseReverse {
Public String reverse (String s) {
The StringBuilder buf=new StringBuilder ();
Char [] ch=s.t oCharArray ();
For (int I=ch. Length - 1; I>=0; I -) {
If (Character. IsLowerCase (ch) [I]) {
Buf. Append (Character. ToUpperCase (ch [I]));
} else if (Character. IsUpperCase (ch) [I]) {
Buf. Append (Character. ToLowerCase (ch [I]));
} else {
Buf. Append (ch [I]);
}
}
return buf.toString();
}
Public static void main (String [] args) {
Scanner sc=new Scanner(System.in);
System. The out. Printf (" both Please input a string: ");
String s=sc. NextLine ();
CaseReverse cr=new CaseReverse ();
System. The out. Println (cr. Reverse (s));
}
}
CodePudding user response: