General Java Questions III
"return null", but will leave the "assign target" as it was.
Tor Iver Wilhelmsen
Q: What does mean "volatile"?
For the past couple of hours, I ve seen quite a few set of codes that has the
_volatile_ keyword.
E.g.
private volatile somethingsomething....
What does it mean?
Answer: See JLS 2nd Edition, which just came out last year, still mentions it.
http://java.sun.com/docs/books/jls/second_edition/html/classes.doc.html#36930
"A field may be declared volatile, in which case a thread must reconcile its working
copy of the field with the master copy every time it accesses the variable. Moreover,
operations on the master copies of one or more volatile variables on behalf of a
thread are performed by the main memory in exactly the order that the thread
requested."
Seems just like the idea in C++ and appears still to me present in the language.
Synchronization certainly has it place in many applications, that doesn t mean that
volatile is not longer used or part of the language.
Paul Hill
Q: If some method is deprecated does it mean that one get a chance not to find
this method in some Java version?
Answer: It means it *may* be dropped in a future version, but chances are it s still
there. I m not sure I ve seen any deprecated features actually being removed from an
API yet often they re turned into no ops first, if they re dangerous.
Jon Skeet http://www.pobox.com/~skeet
Q: suppose I put a file a.txt in package com.xyz and the try access it like
following. Will it work?
import com.xyz.*;
public class Hello{
File f = new File("a.txt");
...
}
it is not working for me. Is there any workaround?
Answer: If the source and the text file are in the jar file, then you access the file by:
URL fileURL = getClass().getResource("file.txt");
You can then read the file by using a reader (or whatever you choose),
e.g.:
file:///F|/a_jsite/350_tips/general_java III.htm (3 of 9) [2001 07 08 11:24:53]
footer
Visionwebhosting.net Business web hosting division of Web
Design Plus. All rights reserved