课程: Java Essential Training: Syntax and Structure
今天就学习课程吧!
今天就开通帐号,24,700 门业界名师课程任您挑!
Text blocks
- [Instructor] Representing multiple lines of texts within a string can be very tedious. Notice how all of the quotation marks need to be escaped. New line characters are needed for each line break and plus signs are needed to join each line. Text blocks allow you to use three quotation marks to open and close a big block of text. With text blocks, text cannot begin on the same line as the opening quote or you'll get a compilation error. A new line must be after the opening quotes. This particular example is legal but it is not the preferred way. The preferred way is to have both the opening and closing quotes aligned on their own respective lines with the text block in between. While still strings, text blocks provides a more readable approach to dealing with long complex strings such as JSON or our SQL queries.
随堂练习,边学边练
下载课堂讲义。学练结合,紧跟进度,轻松巩固知识。