字符串文字

A....

A.

Young businesswoman working in an office Stringliteral is a sequence of characters used by Java programmers to populate String "I live at 22b Baker Street!" is a String Although in your Java code you will be writing the text within the quotes, the Java compiler will interpret the characters as Unicode code points. Unicode is a standard that assigns all letters, numbers, and symbols a unique numerical code. This means that every computer will display the same character for each numerical code. This means that if you know the number values you can actually write String "\u0049\u0020\u006C\u0069\u0076\u0065\u0020\u0061\u0074\u0020\u0032\u0032\u0042\u0020\u0042\u0061\u006B\u0065\u0072\u0020\u0053\u0074\u0072\u0065\u0065\u0074\u0021" represents the same String Unicode and normal text characters can also be mixed. This is useful for characters you might not know how to type. For example, a character with an umlaut (e.g., Ä, Ö) as in "Thomas Müller plays for Germany." would be: "Thomas M\u00FCller plays for Germany." To assign a String object a value just use a String String text = "So does Dr Watson";

Escape Sequences

There are certain characters that you might want to include into a String literal which need to be identified to the compiler. Otherwise, it might get confused and not know what the String value is supposed to be. For example, imagine you want to put a quotation mark within a String "So my friend said, "It's how big?"" This would confuse the compiler because it expects all String \" So the String "So my friend said, \"It's how big?\"" Now the compiler will come to the backslash and know the quotation mark is part of the String literal instead of its end point. If you're thinking ahead you're probably wondering but what if I want to have a backslash in my String \\ Some of the escape sequences available don't actually print a character to the screen. There are times when you might want to display some text split by a newline. For example: The first line. The second line. This can be done by using the escape sequence for the newline character: "The first line.\nThe second line." It's a useful way to put a little bit of formatting into one Sting There are several useful escape sequences worth knowing:
  • \用于在文本中插入制表符
  • \宾塞特退格
  • \插入新行
  • \洗车返回
  • \'插入单个引号
  • \“插入双引号
  • \\插入反斜杠

示例Java代码可以在有趣的字符串示例代码中找到。

  • 发表于 2021-10-11 11:51
  • 阅读 ( 164 )
  • 分类:编程

你可能感兴趣的文章

变量(variables)和java中的数据字面值(data literals in java)的区别

...有各种类型的文字。它们是整数文本、浮点文本、字符和字符串文本。整型字面值用于初始化整型数据类型(如byte、short、int和long)的变量。浮点字面值用于初始化数据类型为float和double的变量。浮点文字以f或f结尾,它是float...

  • 发布于 2020-10-19 08:52
  • 阅读 ( 258 )

片假名(katakana)和平假名(hiragana)的区别

...单词的书写系统。平假名和片假名演变成两个独立的音节文字或音节。今天,书写系统是由片假名、平假名和第三种汉字的混合体组成。许多人试图把日语作为一门外语来学习,却没有意识到片假名和平假名之间的区别。本文将...

  • 发布于 2020-11-02 18:18
  • 阅读 ( 1735 )

汉字(kanji)和平假名(hiragana)的区别

...背景信息。现在,你会相信日本人早在公元4世纪就没有文字文字了,不得不通过韩国从中国进口文字来改编并作为自己的文字使用吗?随着时间的推移,日语演变出了一种有位置的汉字字体,这个过程导致了平假名和片假名两...

  • 发布于 2020-11-02 19:39
  • 阅读 ( 344 )

6个免费的在线工具,下载文本到语音作为mp3音频

文本到语音转换工具帮助您将书面文字转换为口头文字。这些年来,文本到语音技术已经取得了长足的进步,有**和**的声音,不同的口音,以及控制音量、音调、速率等的能力。 ...

  • 发布于 2021-03-30 20:10
  • 阅读 ( 444 )

你怎么做颠倒的文字?

你见过有人在网上用倒过来的文字吗?你想过怎么做吗?让我们快速看一下角色是如何实际组合在一起的,并向您展示一个简单的生成器,它将为您完成这项工作。 倒过来的文本实际上只是一种技巧,它使用特殊的Unicode符号,...

  • 发布于 2021-04-08 12:25
  • 阅读 ( 195 )

什么是字符编码像ansi和unicode,他们有什么不同?

...是不重要的!)。有些语言,如古埃及语和汉语,有表意文字;这些文字代表的是整个思想而不是声音,它们的发音可以随着时间和距离的变化而变化。如果你用一个字符替换另一个字符,你就是在替换一个想法。它不仅仅是改...

  • 发布于 2021-04-09 01:48
  • 阅读 ( 247 )

你现在可以直接在facebook上分享引用的文字

...阅读器中内置了报价分享功能。现在,你不用把Kindle上的文字复制粘贴到Facebook上,只需突出显示并分享给Facebook即可。Facebook将把文本粘贴到一个新的block-quote格式的帖子中,并包含原始URL的完整预览。这与media去年推出的在Twitt...

  • 发布于 2021-05-04 04:48
  • 阅读 ( 165 )

假名(kana)和汉字(kanji)的区别

假名Vs 汉字 假名和汉字,这两种典型的日本文字,可能在某些方面看起来相似,因为他们属于几乎相同的类型。但人们可能会遇到更多的差异,而不是在假名和汉字之间的相似之处。 汉字是象形汉字,假名是音节日语。 汉字...

  • 发布于 2021-06-22 19:00
  • 阅读 ( 503 )

编码(encoding)和解码?(decoding?)的区别

...的格式。 可能,我们知道的最早的编码形式之一是象形文字;古埃及文字使用图片,而不是我们很容易理解的字母词。 这些精心绘制的符号非常适合装饰寺庙的墙壁,但为了进行日常事务,还有另一个脚本,称为hieratic。这是...

  • 发布于 2021-06-24 23:38
  • 阅读 ( 320 )

平假名(hiragana)和片假名(katakana)的区别

...语书写系统的基本组成部分。它可以作为基本的日语语音文字介绍,因为它代表了日语文字中的每一个声音。日语中的所有发音都可以用这个脚本来写。日语中有46个基本的现代平假名字符。它有5个单数元音,45个辅音-元音联合...

  • 发布于 2021-06-27 08:04
  • 阅读 ( 770 )
彤彤彤彤-
彤彤彤彤-

0 篇文章

相关推荐