Java String Reverse reverse(String word)

Here you can find the source of reverse(String word)

Description

reverse

License

LGPL

Declaration

public static String reverse(String word) 

Method Source Code


//package com.java2s;
//License from project: LGPL 

import java.util.ArrayList;
import java.util.Collection;

import java.util.List;

public class Main {
    public static String reverse(String word) {
        char[] chars = word.toCharArray();
        int size = word.length();
        for (int li = 0, ri = size - 1; li < ri; li++, ri--) {
            char swap = chars[li];
            chars[li] = chars[ri];//  w  w w  . java  2s.  co  m
            chars[ri] = swap;
        }
        return new String(chars);
    }

    public static List<char[]> toCharArray(Collection<String> patterns) {
        List<char[]> charpatterns = new ArrayList<char[]>(patterns.size());
        for (String pattern : patterns) {
            charpatterns.add(pattern.toCharArray());
        }
        return charpatterns;
    }
}

Related

  1. compareVersion(String va, String vb)
  2. getReverseShelfKey(String shelfkey)
  3. reverse(String aPackage)
  4. reverse(String s)
  5. reverse(String text)
  6. reverseCommaDelimitedString(final String string)
  7. reverseDelimited(String str, char separatorChar)
  8. reverseUseSB(String str)