1. String encryption
Design ideas:
Each character can be converted to an integer type, can also convert the integer type to a character type, so that we in the encryption time due to push 3 backward , so we can convert the character to shaping, and then add 3, after the operation of the variable into a character after the output, you can implement string encryption.
Program Flowchart:
input string -"break the string into characters-" character to reshape-"reshape plus 3-" Convert to Character-"output."
Source:
Import Java.util.Scanner;
public class Miwen {
public static void Main (String args[])
{
char temp;
int b;
SYSTEM.OUT.PRINTLN ("Please input string:");
Scanner Scanner = new Scanner (system.in);
String a = Scanner.next ();
int N=a.length ();
for (int i=0;i<n;i++)
{if (A.charat (i) < ' x ')
{Temp=a.charat (i);
b= (int) temp;
B=b+3;}
Else
{Temp=a.charat (i);
b= (int) temp;
b=b-23;}
temp = (char) b;
SYSTEM.OUT.PRINTLN (temp);
}
}
}
2.string.equals () method
"= =" Determines whether two objects are identical, i.e. content and address, while equals () compares content only, such as judging S1 and S2 content format s1.equals (S2);
3. Defragment the String class length (), CharAt (), GetChars (), replace (), toUpperCase (), toLowerCase (), Trim (), ToCharArray () usage instructions
Length () is used to find the lengths of the strings, and the return value is the length of the string.
CharAt () takes the character of the string at a location, starting with 0, as the char type
GetChars () copies the characters in this string to the target character array
Replace () replaces the element or substring in the original string. Returns the replaced string
toUpperCase () to capitalize characters in string strings
toLowerCase () to lowercase characters in string strings
Trim () The header of the stripped string is a space
ToCharArray () Converts a string to a character array
Java Classroom Encryption