字符串和文字有什么区别?
“我喜欢计算机科学!”是什么类型?我很确定它是字符串或文字,任何人都可以指出两者之间的区别并帮助我找到答案
What is the type of "I like Comp Sci!"? I'm pretty sure its either a string or a literal, can anyone point out the difference between the two and help me find the answer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
字符串是字符序列。文字是作为程序的一部分输入的数据。如果您在程序中输入了
“I like Comp Sci”
,那么它就是一个字符串文字。A string is a sequence of characters. A literal is data that's typed in as part of the program. If you have
"I like Comp Sci"
typed into your program, then it's a string literal.在大多数语言中,它既被视为字符串又被视为文字。字符串是组成一段文本的字符的集合。文字是直接输入到源代码中的无条件常量。它们并不相互排斥。
In most languages, it would be considered both a string and a literal. A string is a collection of characters that make up a section of text. A literal is an unconditional constant which is directly entered into your source code. They are not mutually exclusive.
字符串是一种数据类型,但字符串字面量是指通常用引号定义字符串的情况:
在示例中,String 是类型,myString 是变量或引用名称,引号中的文本是一个文字字符串。
A string is a data type, but a string literal is when a string is defined literally usually in quotes:
In the example String is the type, myString is a variable or reference name, and the text in quotes is a literal string.