General Java Questions I
to import all the classes in a package.
Answer: Strictly speaking, "import java.util.*;" does not import the whole of java.util. It
is an "import on demand" which imports any class or interface in java.util that is
needed. If the first import statement would have done the job, then HashMap is the
only class the second one would import.
No measurable differences in compile time performance. You can do the test, but I
suspect you would get identical byte code, so no difference in run time performance.
There is a practical difference when two packages contain classes with the same
name. Suppose you also imported java.awt.* and tried to declare a List. It would be
ambiguous. If you use the second form you would either import java.util.List or
java.awt.List.
There is also a documentation difference. The first one makes it clear exactly what
imported classes are being used. 
by Patricia Shanahan
Q: == and equals ()... These two still make me confuse a lot of time.
Can somebody give me some thumb rule or explain it to me?
Answer: When you use == with a primitive  int, double, char, ... you are checking that
the values are identical. But if you use == with an object, you are checking that the 2
objects are stored at the same address. In other words the references pointing to the
same object...
Method equals () is different.
It is the same as ==, if it isn t overriden by the object class.
Many classes override the method equals (). In this case this method will check that
content of the object is the same or not, not addresses.
 Q: Why do I get message like  wrong magic number  when I am trying to run
applet? What is magic number?
Answer: The first thing a JVM does when it loads a class is check that the first four
bytes are (in hex) CA FE BA BE. This is the "magic number" and thats why you are
getting that error, you are trying to load a file that isnt a class and so the class loader
in the JVM is throwing out that exception.
Make sure you transfer the class files to site in binary mode, rather than text or ASCII
mode. 
An error from the browser saying "cannot start applet ... bad magic number" usually
means that one of the class files on the server is corrupted.  
Replace your class binary files on the web server; clean up the cache of your
browser, and reload your applet.
Q: In java, I found a lot of methods, which let you enter a line (read (), readLine ()
e.c.t). They all wait until return is pressed, and then start providing you the
information.
Does anyone know if there is a read method available whit the desired behaviour, i.e.
which doesn t wait for return being pressed?
file:///F|/a_jsite/350_tips/general_java I.htm (11 of 33) [2001 07 08 11:24:51]






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

java web hosting

 

Visionwebhosting.net Business web hosting division of Web Design Plus. All rights reserved