JavaLanguage Section Index | Page 3
Is it possible to get a file's creation date in Java?
It is not possible to obtain this information on *nix machines since this information is not stored about the files, only file modification date is stored. Therefore java has no methods for obtai...more
If you have a series of objects with a circular reference, can they be garbage collected?
Yes. If the objects are only reachable from themselves and nowhere else, they are a candidate for garbage collection.
What are the differences between a shallow clone of an object and a deep clone?
By default, cloning yields a shallow copy. By shallow, we mean the object is copied, but the contained objects are not. What a deep copy does it copy the cloned object, as well as all the objects...more
What is the difference between variable arity and vararg methods?
Basically nothing. It is just semantics. A method's arity is the number of arguments it takes. The arity of the main() method of a class is one since it takes one argument, a String[].more
When was J2SE 1.3 released?
May 8, 2000. See the press release at http://www.sun.com/smi/Press/sunflash/2000-05/sunflash.20000508.3.html.more
When was J2SE 1.4 released?
February 6, 2002. See press release at http://www.sun.com/smi/Press/sunflash/2002-02/sunflash.20020206.5.html.more
When was J2SE 5.0 released?
September 30, 2004. See press release at http://www.sun.com/smi/Press/sunflash/2004-09/sunflash.20040930.1.html.more
When was Java 1.0 released?
January 23, 1996. See the initial press release at http://www.sun.com/smi/Press/sunflash/1996-01/sunflash.960123.10561.html.more
When was Java 2 released?
Technically called Java 2 Standard Edition, version 1.2, it came out December 8, 1998. See press release at http://www.sun.com/smi/Press/sunflash/1998-12/sunflash.981208.9.xml.more
When was JDK 1.1 released?
February 19, 1997. See the press release at http://www.sun.com/smi/Press/sunflash/1997-02/sunflash.970219.0001.html.more
How do I check if a String is empty?
Assuming it isn't null, it is best to just check its length.
String s = ..;
if (s.length() == 0) {
System.out.println("I'm empty");
}
You may want to trim() the contents first to remov...more
Can I have a variable length argument at a position other than the last one?
No, variable length arguments are only supported as the last argument passed into a method.
Does Java support covariant return types?
As of JDK 5.0, yes.
From within a method, how do I access a variable length argument?
Arguments identified to be variable length are accessed like an array. So, to find out its length, you would check with argname.length, to access a specific entry, you would use argname[x], where ...more
What are covariant return types?
A method in a subclass returning an object whose type is a subclass of the type returned by the method with the same signature in the superclass.