General Java Questions I
Keep in mind that Sun s programmers haven t been very good at actually
documenting this for all classes and methods.
or directly here:
To check your code against any version of the JRE (1.1, 1.2, 1.3), use
JavaPureCheck: http://java.sun.com/100percent/
Marco
Q: How do we exchange data between Java and JavaScript and vice versa?
Answer: Public variable and methods of Java Applet are visible to a HTML document.
So using JavaScript you can access the public variables and public functions.
The syntax is:
var some_var = document.appletname.variable_name
With this you will get the value of the variable variable_name in your JavaScript
variable some_var.
Q: Constructors and methods: are they the same?
I need a little help here...I have been teaching that constructors are not methods. This
is for several reasons, but mainly because JLS says "constructors are not members"
and members are "classes, interfaces, fields, and methods."
So, now the rest of the staff is ganging up on me and making life a little nasty. They
quote Deitel and Deitel, and Core Java (which references "constructor methods") and
who knows how many other books.
The one we are teaching in is loaded with so many errors that even though it calls
constructors methods NOBODY will quote it as an authority.
How can so many people call constructors methods if they aren t.
Okay. Are they or aren t they? I holding to the definition that they are not unless it is
so common to call them that, that I will have to change.
Comments?
Answer: If you go by the JLS (Java Language Specification) and the Java API (and
you should) , then no, constructors are not methods. Consider that
Class.getMethods() returns an array of Method instances and
Class.getConstructors() returns an array of Constructor instances, and Constructor
and Method or not interchangeable (one is not derived from the other), but both
implement the Member interface. Seems to me that Java is going out of its way to
differentiate them.
Besides, the mechanics of constructors are so different from the mechanics of
methods, there seems to be no value to considering one a member of the set of the
other.
Now, as far as teaching the language goes:
Methods:
+ return types
+ called by name
+ executed multiple times
Constructors:
file:///F|/a_jsite/350_tips/general_java I.htm (4 of 33) [2001 07 08 11:24:51]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved