Core Java Technology Section Index | Page 5
What is the primary difference between pessimistic and optimistic concurrency control?
Pessimistic assumes conflicts will occur and avoids them through exclusive locks and explicit synchronization. With the optimistic approach, it is assumed conflicts won't occur, and they are dealt...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
How do you get the output of a Java program in a text file instead of getting it on the console?
You can get the output into a file instead of the console / command prompt as follows:
System.setOut(new PrintStream(new FileOutputStream("Test.txt")));
System.out.println("Hello How r u");
No...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
How do I create a method that accepts a variable number of arguments?
Variable arity or vararg methods were added to JDK 5.0. The last argument to a method can be declared as Type... name, where Type is the Java class type for the argument, and name is how it is ac...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.
Why did the toURL() method of File get deprecated in Java 6? Should I stop using it now.
The toURL() method of File does not properly escape characters that aren't valid in a URL. You can write better code today without waiting for Java 6 by calling the toURL() method after calling to...more