Home > Java > javaTutorial > Java Example - String Reverse

Java Example - String Reverse

黄舟
Release: 2017-02-21 10:09:28
Original
1906 people have browsed it

The following example demonstrates how to use Java's reverse function reverse() to reverse a string:

public class StringReverseExample{
   public static void main(String[] args){
      String string="abcdef";
      String reverse = new StringBuffer(string).
      reverse().toString();
      System.out.println("\nString before reverse:
      "+string);
      System.out.println("String after reverse:
      "+reverse);
   }}
Copy after login
The output result of the above code example is:
String before reverse:abcdef
String after reverse:fedcba
Copy after login

The above is the Java example - character For string reversal content, please pay attention to the PHP Chinese website (www.php.cn) for more related content!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template