public class PaiXu {
public static void main(String[] args) {
String str = "abcd";
String strr = "";
strr = new StringBuffer(str).reverse().toString();
System.out.println(strr);
}
}
***************************************************
***************************************************
public class Reverse{
public static void main(String[]args){
String s="abcd";
String rs="";
for(int i=s.length()-1;i>=0;i--)
{
rs+=s.charAt(i);
}
System.out.println(rs);
}
}
***************************************************
***************************************************
public class Test5 {
public static void main(String[] args) {
String str = "123456789";
System.out.println(reverse(str));
}
public static String reverse(String str) {
if(str == null || str.length() < 2) {
return str;
}
char[] chs = str.toCharArray();
for(int i = 0, k = chs.length / 2; i < k; i++) {
char c = chs[i];
chs[i] = chs[chs.length - i - 1];
chs[chs.length - i - 1] = c;
}
return new String(chs);
}
}
***************************************************
***************************************************
public class PaiXu {
public static void main(String[] args) {
String str = "abcd";
String rstr = "";
char[] nc = str.toCharArray();
for (int a = 1; a <= nc.length ; a++) {
rstr += nc[nc.length - a];
}
System.out.println(rstr);
}
}