Java post-class jobs

Source: Internet
Author: User

After-school assignment string encryption:

Design ideas:

1. Enter the English substring to encrypt str

2. Define the string length of the Num=str

3. Convert a string to a single character

4. Each character +3, move backwards by 3

5. Define STR1, multibyte the newly obtained word to str1, and get the encrypted English substring str1

6. Output encryption after the English sub-string str1

Source:

Import Java.util.Scanner;

public class Test {

public static void Main (string[] args) {

TODO auto-generated method stubs

Scanner input=new Scanner (system.in);

System.out.println ("Please enter the English substring to encrypt:");

String str;

int num=0;

Str=input.nextline ();

Num=str.length ();

Char A;

int num1=0;

String Str1=new string ();

for (int i=0;i<num;i++)

{

A=str.charat (i);

A= (char) (A+3);

Str1=str1+a;

}

SYSTEM.OUT.PRINTLN ("The Encrypted English substring is: \ n" +str1);

}

}

Results:

The hands of the brainstring.equals ()Method:

String.Equals() is used to determine whether the contents of two string objects are the same, and = = determines whether the references to two string instances are the same , that is, whether the first address is the same.

FinishingStringClass ofLength (),charAt (),GetChars (),replace (),toUpperCase (),toLowerCase (),Trim (),ToCharArray ()Instructions for use

Length () can be used to find string lengths.

CharAt () gets the character at the specified position.

GetChars () Gets a string from the specified position copied to the character array, such as s.getchars (0,5,chararray,0); Four the meaning of a parameter: 1. Span style= "font-family: ' Times New Roman ';" >2. The last character copied is subscript in the string. +1 3. 4. The copied character is placed in the character array starting with the subscript.

Replace () substring substitution, such as replace(old,new), with new strings instead of older strings.

toUpperCase (), toLowerCase () case conversion.

Trime () removes the Kinsoku space.

ToCharArray () converts a string object to a character array

Java post-class jobs

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.