感觉效果很好, 输入文字和代码都很方便,专注于写作,是写博客的好助手。 推荐大家试用。
Writed was created by Stahl Labs AB to
provide the best distraction free
writing tool for Mac.
*
This program is used to reverse the string.
*/
// reverse string
import java.util.*;
public class ReverseStr{
public static void main(String[] args) {
String[] strArr = { "hello world", "", "iammai" };
for( String str: strArr)
System.out.println(String.format(" %s -> %s ", str, reverseStr(str)));
}
public static String reverseStr( String str) {
String res = "";
if (str.length() == 0 || str == null) return str;
for(int i= str.length()-1; i>= 0 ; i--) {
res += str.charAt(i);
}
return res;
}