2

When I use String in Java do I need to import java.lang.String? Or I can simply use it?

Is String imported by default? I am using Eclipse and as I know they use another compiler that Java does. What is the standard way?

3

5 Answers 5

8

No, java.lang.* is imported by default.

1

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.

1

You don't need to formally import java.lang.String .. would represent being "overly redundant" when reading code.

0

By default, Java classes import all java.lang classes. It's pretty rare to see Java code that explicitly imports java.lang.String.

0

No, it is imported. use :String [name] = "[value]";

Not the answer you're looking for? Browse other questions tagged or ask your own question.