27.04.2013 Views

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

330 Java Tips.pdf - FTP Server

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

General <strong>Java</strong> Questions II<br />

public MyEnumeration(Vector v){<br />

size = v.size();<br />

e = v.elements();<br />

index = 0;<br />

}<br />

public boolean hasMoreElements(){<br />

return e.hasMoreElements();<br />

}<br />

public Object nextElement(){<br />

index++;<br />

return e.nextElement();<br />

}<br />

public int size(){<br />

return size;<br />

}<br />

public int getIndex(){<br />

return index;<br />

}<br />

}<br />

-by<br />

Nicolas Delbing and Victor Vishnyakov<br />

Is there a way to provide values for a Vector in the source code, analogous to<br />

array initializers?<br />

Answer: The Vector class constuctors take no arguments other than Collection (since<br />

JDK 1.2), which is abstract, and since a Vector is a structure whose size can change<br />

dynamically, it's contents can only be initialaized through member methods.<br />

--<br />

Mike Lundy<br />

How would I add a help file to a java application?<br />

Would it have to be platform specific, or is there a <strong>Java</strong> api for making help files?<br />

If so, what is it?<br />

Answer: See <strong>Java</strong>Help at http://www.javasoft.com/products/javahelp/<br />

you create HTML pages for the main text, and add some XML files for a hierarchical<br />

table of contents and a map from TOC tags to relative URLs giving document<br />

locations.<br />

What is a Just-In-Time(JIT) compiler?<br />

Answer: It is a JVM that compiles <strong>Java</strong> instructions (called bytecode) into native<br />

machine instructions at run time and then uses this compiled native code when the<br />

corresponding <strong>Java</strong> code is needed. This eliminates the constant overhead of<br />

interpretation which tradition first generation JVM's used.<br />

--<br />

Dave Lee<br />

Is there a collection object like the hashmap or hashtable that stores values in an<br />

file:///F|/350_t/350_tips/general_java-II.htm (6 of 13) [2002-02-27 21:18:24]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!