public static void reverse() {
int x=0;
char temp = 0;
String toStrore;
char checkSpace=' ';
System.out.println("Enter a line to reverse");
Scanner sc=new Scanner(System.in);
String userInput=sc.nextLine();
char[] charArray=userInput.toCharArray();
for(int i=charArray.length-1;i>=0;i--){
char tchar=charArray[i];
while(tchar==checkSpace){
x = ++i;
for(int j=x;j<=charArray.length-1;i++){
temp=(char) (temp+charArray[j]);
System.out.print(temp);
}
}
}
}
请帮我讲逻辑。
注意:我不想使用任何内置函数,除了长度()。