具体步骤如下:
package test;
import java.util.Scanner;
public class zhengshufanzhuan {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("请输入反转的数据:");
String str = sc.nextLine();
String y = reverse(str);
System.out.println(y);
}
public static String reverse(String str) {
StringBuffer sb = new StringBuffer(str);
String str2 = sb.reverse().toString();
return str2;
}
}
可以输入任意类型的数据:byte类,short类,char类,int类,long类,float类,double类