Recent Notes
Displaying keyword search results 91 - 100
Created by meiu on July 29, 2009 19:30:35
Last update: July 29, 2009 19:30:35
Without the break statement, the Java switch/case block looks very deceptive.
Code:
public class TestCase {
public static void ...
Test:
C:\tmp>java TestCase
No arguments
One argume...
Created by James on May 23, 2009 19:46:01
Last update: May 23, 2009 19:49:46
This topic comes up once in a while: I need to generate a random string in JavaScript to get around browser (IE) cacheing.
Method 1 (not really random, but a new value every millisecond):
function randomString() {
return '' + n...
Method 2 (generate a random alpha-numerical string):
function randomString(length) {
var chars =...
Created by Dr. Xi on February 09, 2009 23:14:15
Last update: February 09, 2009 23:14:15
This example demonstrates the general steps in creating a custom Java class loader. Normally a class loader would consult its parent class loader when asked to load a class. If it's not loaded by the parent class loader, then the class loader would try to load the class on its own. This class loader tries to load the requested class on its own first, and delegates to the parent only when a java.lang.SecurityException is thrown (which happens when it tries to load core Java classes such as java.lang.String ). The classes are loaded from CLASSPATH through the getResourceAsStream call. It's important to note that when a class is loaded with a certain class loader, all classes referenced from that class are also loaded through the...
Created by Dr. Xi on November 19, 2008 23:52:22
Last update: November 19, 2008 23:52:22
// Removes the 4-letter words from c
static voi...
Created by Dr. Xi on October 16, 2008 23:09:28
Last update: October 17, 2008 03:30:38
import java.io.*;
public class TestMSOffice...
Created by Dr. Xi on October 15, 2008 22:20:01
Last update: October 15, 2008 22:20:01
import java.security.MessageDigest;
import java...
Created by Dr. Xi on October 15, 2008 18:34:17
Last update: October 15, 2008 18:34:17
class InitializeStringArray {
public static...
Created by Dr. Xi on September 25, 2008 02:58:27
Last update: October 14, 2008 22:49:32
This following code came from a JavaWorld tip, with some minor modifications.
public class JWhich {
/**
* Retu...
Created by Dr. Xi on October 04, 2008 04:13:57
Last update: October 04, 2008 04:15:22
substr returns a substring beginning at a specified location and having a specified length . substring returns a substring by specifying the start and end index.
s = 'She-sells-sea-shells-by-the-sea-shore';
s....
But really, providing two options does not make things better. Either one gets the jobs done. Two options just create more confusion.
Created by Dr. Xi on October 04, 2008 01:41:16
Last update: October 04, 2008 02:16:22
Java Java requires the expression to be type boolean . There are only two possible values for a boolean : true or false . Using any other data type in a boolean context (such as an if condition) is an error. C# C# supports a strict boolean type, bool . Statements that take conditions, such as while and if , require an expression of a boolean type. C# disallows this "integer meaning true or false" approach on the grounds that forcing programmers to use expressions that return exactly bool can prevent certain types of programming mistakes such as if (a = b) (use of = instead of == ). Perl A scalar value is interpreted as TRUE in the Boolean sense if it is not...