Java string The first character and the last character reverse the position test

Source: Internet
Author: User
Tags first string

A recent requirement was to connect to our system via OA, and then request to have the Base64 encrypted string, and the first and last position reversed, so you need to restore the normal encryption string before decrypting.

So the first thing to do is to test and restore the encrypted string, that is, the first one with the most one character position exchange.

The test code is as follows:

private static void Test2 () {String st= "012345 =";  String firstchar=string.valueof (St.charat (0));  String lastchar=string.valueof (St.charat (St.length ()-1));  String middlestring=st.substring (1,st.length ()-1);   String Str=lastchar+middlestring+firstchar;  System.out.println ("Original string:" +st); System.out.println ("First string:" +firstchar); System.out.println ("Last string:" +lastchar); System.out.println ("The middle string:" +middlestring); System.out.println ("String after combination:" +str);}

Results:

Original string: 012345 =
First string: 0
Last string: =
Middle of string: 12345
String after combination: =123450

Java string The first character and the last character reverse the position test

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.