Here you can find the source of reverse(String word)
public static String reverse(String word)
//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; } }