[1903] in java-interest
Re: mo betta questions
daemon@ATHENA.MIT.EDU (Chuck McManis)
Tue Sep 19 20:09:36 1995
Date: Tue, 19 Sep 1995 12:36:16 -0700
From: cmcmanis@scndprsn.Eng.Sun.COM (Chuck McManis)
To: fgreco@lehman.com
Cc: java-interest@java.Eng.Sun.COM
>1. Where can I find the language spec? Am I the only one that
> is wishing for an old-fashioned documentation set (ie, a *decent*
> PS book-like version)?
You mean the other than the one that you get by going to the URL
doc:///doc/javaspec/javaspec_1.html ?
>2. The on-line tutorial shows "System.out.println()" and explains that
> "System" is the class. There was no import statement, so where
> did this class come from? And what exactly is "out"? Is it
> a subobject of System?
In the HotJava browser, try the Help->Search the Documentation menu.
You will find the API for System (which is part of java.lang)
> Where are the docs on System? I cannot seem to find any.
Distributed with the browser. They are also available on the web site.
>3. If "java.util" is a package, what is the "java" prefix telling me?
That it is part of the packages that Sun provides. There is no semantic
beyond this in package names.
>4. I'm assuming every object has a fully qualified name:
> pkg.class.object[.method|.variable]
Yes, within the class space the objects are unique by <package>.<class>
> Can someone correct me if I'm wrong? The docs say "package
> names are period-separated words"... this is ambiguous.
This is stated more clearly in the new spec. Basically treat them as
an opaque string.
>5. I don't see parameterized types? Does Java have this feature?
Not in 1.0 we're looking at it for a later version of the language.
>6. How can one embed the java interpreter into a C/C++ pgm a la tcl?
> If this is possible, can you have multiple instances of the interpreter?
This is not currently possible to do. You can however have several
instances of the interpreter running in different processes.
>7. How is an applet auto-started (ie, started after it is downloaded)?
The browser fetches the applet using HTTP and then invokes the init()
method on it and adds it to the list of applets on the page. Once all
applets are loaded and 'inited()' they are started and painted.
>8. How can an applet-writer *selectively* allow users to use their applets?
Based on what selection criteria? You can put applets on pages accessible
only to "selected" people. You can mail to selected people a "key" to store
in their ~/.hotjava directory that the applet looks for, etc. The list goes
on, its a programming language after all :-)
>9. I noticed the disassembler "javap" is mentioned. How can I prevent
> users from reverse-compiling my applications and applets?
You cannot. You can however design your applets such that they simply
communicate with a service back on your server.
>Can someone give me a decent explanation of what an "interface" (wrt
>java of course) is? I cannot grok what the docs are trying to say. Is
>it basically a class-ish way of organizing abstract methods?
Use interfaces when you have a behaviour you would like lots of different
objects to share, use abstract classes when you have an implementation you
would like to share. For example, in java.util there are some classes
that encode and decode binary data into text. The abstract class is
CharacterEncoder and CharacterDecoder. The subclasses such as UUDecoder
add the small piece of functionality that makes a character encoder a
uuencoder. Similarly HexDumpEncoder simply encodes binary in a format
that looks like a hex dump. Most of the implementation is in the super
class and just the specialized part is in the subclass.
Interfaces on the otherhand describe a behaviour without describing
the implementation. So lets say you wanted to build a persistent
object store. You want to be able to put any object that supports
being persistified (neologism?) into your persistant store but you
don't want to, or can't, make _all_ objects persistent. So you
define an interface that has the methods "freeze" and "thaw" which
return/take a "FrozenObject" class. Now you build your persistant
object store to hold FrozenObjects and if you want to put an object
instance into it you can write:
if (Objref instanceof Freezable) {
FrozenObject fz = ((Freezable)(Objref)).freeze();
}
The benefit of the interface is that there need not be a common superclass
to all of the objects in your freezer, only a common interface.
--Chuck
-
Note to Sun employees: this is an EXTERNAL mailing list!
Info: send 'help' to java-interest-request@java.sun.com