What is the difference between Unicode and ASCII? The use of the string class for escape characters in Java character class

Source: Internet
Author: User

ASCII code known as the United States Standard Information Interchange Code (American Standards Code of Information Interchange)

How many yards are there? 2 of 7 Power 128

Unicode code the world of various languages of the United Code table This Code table contains Chinese and English Korean Russian

A total of 65,536

Char letter= ' A ';

System.out.println (letter++);

System.out.println ((char) 65);

System.out.println ("\u0041");

The Code table we used behind is

UTF-8

GBK

\b is called backspace, and its Unicode code is \u0008.

\ t is called Tab key, which is equivalent to pressing TAB

\ n NewLine a line break action is equivalent to a carriage return line \ r \ n

\f Page Change

\ \ Output back slash

\ "Output double quotation marks

Char c= (char) 0xab0041;//a character type of 2 bytes, 16 bits, which is actually converted to the latter 16 bits.

Char c= (char) 65.25;//turns the integer first, then the character

byte b= ' \ufff4 ';//byte occupies a space of its own, 8 bits,

int i= ' 2 ' + ' 3 ';
System.out.println (i);//summation of the ASCII table in decimal and

Character class use

IsDigit (' A ') determines whether a character is a number

System.out.println (i);
if (Character.isdigit (' a ')) {
System.out.println ("This is a number");
}else {
System.out.println ("This is not a number");
}

Second, Isletter (' a ') determines whether the character is a letter

if (Character.isletter (' a ')) {//This is a class name that calls a static method directly, the keyword is static
System.out.println ("This is a letter");
}else {
System.out.println ("This is not a letter");
}

Third, Isletterordigit ()

Letters and Numbers

Four, islowercase judge is the lowercase letter?

V. toLowerCase converted to lowercase letters

Use of the String class

One, to find the length of the string

String s= "Welcome to Java";
System.out.println (S.length ());

Second, the connection string

Concatenate connection

String s= "Welcome to Java";
System.out.println (S.length ());
String s1= "and HTML";
String S2=s.concat (S1);
SYSTEM.OUT.PRINTLN (S2);

We usually use string connectors

String s2=s+s1;
SYSTEM.OUT.PRINTLN (S2);

int x=1;
int y=2;
System.out.println ("x+y=" +x+y);//This is a string connection

C. Convert a string to uppercase or lowercase

Using toLowerCase ()

String s= "Welcome";

System.out.println (S.touppercase ());

The first method next () method "" "" \ T "\ r" \ n "
Scanner input =new Scanner (system.in);
String S1=input.next ();
String S2=input.next ();
String S3=input.next ();
System.out.println (s1+ "~~~~~~" +s2);

The second method type Enter a return line
Scanner input =new Scanner (system.in);
String S3=input.nextline ();
System.out.println (S3);

Four, read one character of a string weight

String s3= "Hello Java";
System.out.println (S3.charat (1));

V. Comparison of strings

Why the following two strings are not equal

String s3 = new String ("Hello Java");
String S4 = new String ("Hello Java");
if (s3 = = S4) {
System.out.println ("equal");
} else {
System.out.println ("unequal");
}

When no object is generated, = = and equals can be determined, but if the object is generated, only equals is used.

String s3 = new String ("Hello Java");
String S4 = new String ("Hello Java");
if (S3.equals (S4)) {
System.out.println ("equal");
} else {
System.out.println ("unequal");
}

String is special, you can use a string without generating an object, such a string in an in-memory string pool, the same string placement in the same position, you can use = = to determine

String s3 = "Hello Java";
String S4 = "Hello Java";

What is the difference between Unicode and ASCII? The use of the string class for escape characters in Java character class

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.