Java String Reverse reverseUseSB(String str)

Here you can find the source of reverseUseSB(String str)

Description

reverse Use SB

License

Apache License

Declaration

public static String reverseUseSB(String str) 

Method Source Code

//package com.java2s;
/**//from ww  w. ja va  2  s. c  om
 * HashMap?????????????????????????new??????????????????????????
 * ????????
 * code by guava-libraries.(Apache License 2.0)
 * https://code.google.com/p/guava-libraries/
 *
 * @return HashMap????????????????????????
 */

import java.util.ArrayList;

public class Main {

    public static String reverseUseSB(String str) {
        String result = new StringBuffer(str).reverse().toString();
        return result;
    }

    public static String toString(ArrayList<Character> characters) {
        Character[] array = characters.toArray(new Character[0]);
        char[] chars = new char[array.length];
        for (int i = 0; i < array.length; i++) {
            chars[i] = array[i];
        }
        String result = new String(chars);
        return result;
    }

    public static String toString(char c) {
        return String.valueOf(c);
    }

    public static String toString(int value) {
        return value + "";

        // return String.valueOf(value);
    }

    public static void reverse(int[] values) {
        for (int i = 0; i < values.length / 2; i++) {
            int tmp = values[values.length - i - 1];
            values[values.length - i - 1] = values[i];
            values[i] = tmp;
        }
    }

    public static String reverse(String str) {
        char[] charArray = str.toCharArray();
        char[] resultChar = new char[charArray.length];
        for (int i = 0; i < charArray.length; i++) {
            resultChar[i] = charArray[charArray.length - i - 1];
        }
        String result = new String(resultChar);
        return result;
    }

    public static char[] toCharArray(String str) {
        char[] result = str.toCharArray();
        return result;
    }
}

Related

  1. reverse(String s)
  2. reverse(String text)
  3. reverse(String word)
  4. reverseCommaDelimitedString(final String string)
  5. reverseDelimited(String str, char separatorChar)