Java section 10th First knowledge string

Source: Internet
Author: User

2016-06-28

1 String variables
String class
"Hello world!"
"This is a string"

 PackageDay10; Public classteststring { Public Static voidMain (string[] args) {//String mystring;//mystring= "Hello world!";//System.out.println (mystring);String name= "Tom"; String Sex= "Male"; String from= "China"; String Info= "The name is:" +name+ "\ n sex is:" +sex+ "\ n from:" +From ;    SYSTEM.OUT.PRINTLN (info); }}

2 String Connection
You can use + to connect two strings, + here is a join operator

Escape characters:
Each escape character consists of two symbols, but the compiler treats him as a character
\ n A newline character is another line, and the cursor moves to the beginning of the next line
\ t tab
\ r Carriage return moves the cursor to the beginning of the bank

 Package Day10;  Public class Testtrans {        publicstaticvoid  main (string[] args) {        //  declares a string that contains an escape character string        teststr= "double quotation mark \" single quotation mark \ ' backslash \ \ Next line \ n tab \ t return character \ r ";        System.out.println (TESTSTR);        System.out.println (Teststr.length ());}    }

Resources

[1] Java Easy Start Classic tutorial "full version"

Java section 10th First knowledge string

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.