Java 字符串导入 java.lang.String
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22362020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java String import java.lang.String
提问by Alon
When I use Stringin Java do I need to import java.lang.String?
Or I can simply use it?
当我String在 Java 中使用时,我需要导入java.lang.String吗?或者我可以简单地使用它?
Is Stringimported by default?
I am using Eclipse and as I know they use another compiler that Java does.
What is the standard way?
是否String默认导入?我正在使用 Eclipse,据我所知,他们使用 Java 所做的另一个编译器。什么是标准方式?
采纳答案by Marco Acierno
No, java.lang.*is imported by default.
不,java.lang.*默认是导入的。
回答by Martin Dinov
You don't need to import anything from java.lang. It is imported by default. Everything in there is available without a need to explicitly import anything.
您不需要从java.lang. 它是默认导入的。那里的所有内容都可用,无需明确导入任何内容。
回答by bcholmes
By default, Java classes import all java.lang classes. It's pretty rare to see Java code that explicitly imports java.lang.String.
默认情况下,Java 类导入所有 java.lang 类。很少看到显式导入 java.lang.String 的 Java 代码。
回答by ErstwhileIII
You don't need to formally import java.lang.String .. would represent being "overly redundant" when reading code.
您不需要正式导入 java.lang.String .. 在阅读代码时将表示“过度冗余”。
回答by Nuclear_Man_D
No, it is imported. use :String [name] = "[value]";
不,它是进口的。用 :String [name] = "[value]";

