在Java语言中,”String”与”string”有什么区别?

huangapple go评论77阅读模式
英文:

String vs string in java language?

问题

在Java语法中,使用Stringstring(注意大写的"S"和小写的"s")之间有什么区别?请尽可能多地让我知道差异!

英文:

What is the difference between usage of String and string(mind capital "S" and small "s") in Java syntax?
Please let me know the differences as many as you know!

答案1

得分: 1

String string = "string";

`String` 是一种类型 - [java.lang.String][1],而 `string` 只是一个变量的名称。这是它们可以用在不同场景的主要区别。

请查阅文档:

 - [变量][2]
 - [字符串][3]
 - [什么是对象?][4]


  [1]: https://docs.oracle.com/javase/8/docs/api/java/lang/String.html
  [2]: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/variables.html
  [3]: https://docs.oracle.com/javase/tutorial/java/data/strings.html
  [4]: https://docs.oracle.com/javase/tutorial/java/concepts/object.html
英文:
String string = "string";

String is a type - java.lang.String and string is just a name of variable. This is the main difference which leads us to where each can be used.

Take a look on documentation:

答案2

得分: 0

String是Java中的一个类。它被几乎所有人用来存储一系列字符。string是一种'数据类型'。大多数人通常会使用str或string作为String类类型的变量名。
例如:"abc"是一种字符串类型,但是是String类的一个'对象'。
英文:

String is a class in Java. It is used by almost everyone, to store a bunch of characters. string is a type of 'data type'. Most people would generally use str or string for a variable name of the type of class String
For example: "abc" is a type of string, but an 'object' of the String class.

答案3

得分: 0

在Java中,String是一个类名(其完整名称为java.lang.String)。由于java.lang包会被自动导入,您可以如下使用String类:

String myString = "this is my string!";

在Java中没有保留的string关键字,但您可以创建一个以此命名的变量:

String string = "this is a string!";
英文:

In Java, String is a class name (its full name is java.lang.String). As the java.lang package is imported automatically, you can use String class as follows:

String myString = "this is my string!";

There's no reserved string word in Java, but you can create a variable with that name:

String string = "this is a string!";

huangapple
  • 本文由 发表于 2020年10月22日 06:14:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/64472471.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定