Write a flip function to make the string flashback
??
First, turn the whole sentence upside down.
??
Then split the string with a space.
??
Flip a single character and then regroup
??
Package reverseSentence42;
??
public class ReverseSentence42 {
static string reverse (string string) {
char[] array = String.tochararray ();
int i = 0, j = array.length-1;
while (I < j) {
char tem = array[i];
Array[i] = Array[j];
ARRAY[J] = tem;
i++;
j--;
}
return string.valueof (array);
}
static string Reversesentence (String string) {
String Reversedstring=reverse (String);
String[] Splitstrings=reversedstring.split ("");
String resultstring= "";
for (String str:splitstrings) {
Resultstring=resultstring+reverse (str) + "";
}
return resultstring;
??
}
public static void Main (string[] args) {
TODO auto-generated Method Stub
String string= "ABCD EDFs";
System.out.println (Reversesentence (string));
}
??
}
Flip word order