You can use this:
new StringBuilder(hi).reverse().toString()
Or, for versions earlier than JDK 1.5, use java.util.StringBuffer
instead of StringBuilder
— they have the same API. Thanks commentators for pointing out that StringBuilder
is preferred nowadays when there is no concurrency concern.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…