Re: Java
Stefan Ram wrote:
"Jeff Higgins" <oohiggins@yahoo.com> writes:
michalfabisiak, I apologise for the misinformation.
Your first answer was correct, because it will always work
under Java SE. The ?java.lang.? can be omitted only if there
is no ?Character.class? in the classpath. For example, when
class Character {}
is being added to a source file, this source file will still
be perfectly legal Java, and your first solution will still work.
It will not work anymore, when ?java.lang.? is being omitted.
When you do not know, whether someone has ?Character.class? in
his classpath or might add this later, the general answer uses
?java.lang.Character? or ?import java.lang.Character;? at the
start of the compilation unit.
That is not correct.
Classes are retrieved from the classpath based on the fully-qualified name
(FQN). Unless the class is also "java.lang.Character", this situation will
not occur, and if it is, using the FQN obviously is no use anyway.
So ignore all that about the classpath.
We are assuming that your class is not in the default package, and that your
classpath does not include any classes in the default package. Such a
situation is pathological and to be avoided anyway. (It's especially
pathological to craft a classpath that includes classes in the default package
that have the same simple name as API classes.)
Just feel free to omit the "java.lang" package, or include it if you really
want to.
--
Lew