Date: Mon, 1 Mar 2004 11:36:51 -0600
From: Alvaro Fernandez <[log in to unmask]>
Am I correct in saying that Java does not allow for globally
visible objects? Somebody told me that once... If so, that would
be problematic for big arrays, it looks like.
There are globally visible objects.
System.out (or fully specified java.lang.System.out) is one of them;
it is the output stream for normal output (like Unix's fd=1, C's
stdout, C++'s cout and Fortran's unit 6(?)). The rule is that
everything is in a class, every class is in a package. You can put
'public static' fields in classes which means (a) everybody can see
them, and (b) they do not require an instance of the class, and there
are ways to "import" classes from packages. Thus, "java" is a top
level package, "lang" is a subpackage of "java". "System" is class in
the "java.lang" package (which is imported automatically, thus the
lack of typical need for the "java.lang." qualifier). "out" is a
public static field of "System". "System" happens to be one of those
classes that is never actually instantiated; all its fields and
methods are static. "java.lang.Math" is another such package whose
public static fields include "E" and "PI".
|