text:
In this chapter, we introduce the framework of the Java language and some of its fundamental facilities. We don't try to provide a full language reference here; instead, we'll lay out the basic structures of Java with special attention to how it
Java is a language for the Internet. Since the people of the Net speak and write in many different human languages, Java must be able to handle a large number of languages as well. One of the ways in which Java supports international access is through Unicode character encoding. Unicode uses a 16-bit character encoding; it's a worldwide standard that supports the scripts (character sets) of most languages. [1]
Java source code can be written using the Unicode character encoding and stored either in its full 16-bit form or with ASCII-encoded Unicode character values. This makes Java a friendly language for non-English-speaking programmers who can use their native alphabet for class, method, and variable
The Java
type and
objects also support Unicode. But if you're
Most platforms can't display all currently defined Unicode characters. As a result, Java programs can be written with special Unicode escape sequences. A Unicode character can be represented with this escape sequence:
is a sequence of one to four hexadecimal digits. The escape sequence indicates an ASCII-encoded Unicode character. This is also the form Java uses to output Unicode characters in an environment that doesn't
Java stores and manipulates characters and strings internally as Unicode values. Java also comes with classes to read and write Unicode-formatted character streams.
Java supports both C-style block comments delimited by /* and */ and C++ - style line comments indicated by // :
/* This is a multiline comment. */ // This is a single-line comment // and so // is this
As in C, block comments can't be nested. Single-line comments are delimited by the end of a line; extra
indicators inside a single line have no effect. Line comments are useful for short comments within
By convention, a block comment beginning with
indicates a special
doc comment
. A doc comment is designed to be extracted by automated documentation generators, such as the Java SDK's
program. A doc comment is
Here's an example:
/** * I think this class is possibly the most amazing thing you will * ever see. Let me tell you about my own personal vision and * motivation in creating it. * <p> * It all began when I was a small child, growing up on the * streets of Idaho. Potatoes were the rage, and life was good... * * @see PotatoPeeler * @see PotatoMasher * @author John 'Spuds' Smith * @version 1.00, 19 Dec 1996 */
javadoc creates HTML documentation for classes by reading the source code and pulling out the embedded comments. The author and version information is presented in the output, and the @see tags make hypertext links to the appropriate class documentation.
The compiler also looks at the doc comments; in particular, it is interested in the @deprecated tag, which means that the method has been declared obsolete and should be avoided in new programs. The fact that a method is deprecated is noted in the compiled class file so a warning message can be generated whenever you use a deprecated feature in your code (even if the source isn't available).
Doc comments can appear above class, method, and variable definitions, but some tags may not be
Tag |
Description |
Applies to |
@see |
Associated class
Class, method, or variable |
@author |
Author name |
Class |
@version |
Version string |
Class |
@param |
Parameter name and description |
Method |
@return |
Description of return value |
Method |
@exception |
Exception name and description |
Method |
@deprecated |
Declares an item to be obsolete |
Class, method, or variable |
The type system of a programming language describes how its data elements (
Java combines the best features of both statically and dynamically typed languages. As in a statically typed language, every variable and programming element in Java has a type that is known at compile time, so the runtime system doesn't normally have to check the type validity of assignments while the code is executing. Unlike C or C++, Java also maintains runtime information about objects and uses this to allow truly safe runtime polymorphism and casting (using an object as a type other than its declared type).
Java data types fall into two categories.
Primitive types
represent simple values that have built-in functionality in the language; they are fixed elements, such as literal constants and
Numbers, characters, and boolean values are fundamental elements in Java. Unlike some other (perhaps more pure) object-oriented languages, they are not objects. For those situations where it's desirable to treat a primitive value as an object, Java provides "wrapper" classes (see Chapter 10). One major advantage of
Another important portability feature of Java is that primitive types are precisely defined. For example, you never have to worry about the
Type |
Definition |
boolean |
true or false |
char |
16-bit Unicode character |
byte |
8-bit signed two's complement integer |
short |
16-bit signed two's complement integer |
int |
32-bit signed two's complement integer |
long |
64-bit signed two's complement integer |
float |
32-bit IEEE 754 floating-point value |
double |
64-bit IEEE 754 floating-point value |
Those of you with a C background may notice that the primitive types look like an idealization of C scalar types on a 32-bit machine, and you're
Floating-point operations in Java follow the IEEE 754 international specification, which means that the result of floating-point calculations is normally the same on different Java platforms. However, since Version 1.3, Java has allowed for extended precision on platforms that support it. This can introduce extremely small-valued and arcane differences in the results of high-precision operations. Most applications would never notice this, but if you want to ensure that your application produces exactly the same results on different platforms, use the special keyword strictfp as a class modifier on the class containing the floating-point manipulation.
Variables are declared inside of methods or classes in C style. For example:
int foo; double d1, d2; boolean isFun;
Variables can
int foo = 42; double d1 = 3.14, d2 = 2 * 3.14; boolean isFun = true;
Variables that are declared as instance variables in a class are set to default values if they aren't initialized. (In this case, they act much like static variables in C or C++.) Numeric types default to the appropriate flavor of zero, characters are set to the null character ( \0) , and boolean variables have the value false . Local variables declared in methods, on the other hand, must be explicitly initialized before they can be used.
Integer literals can be specified in octal (base 8), decimal (base 10), or hexadecimal (base 16). A decimal integer is specified by a sequence of digits beginning with one of the characters 1-9:
int i = 1230;
Octal numbers are distinguished from decimal numbers by a leading zero:
int i = 01230; // i = 664 decimal
As in C, a hexadecimal number is denoted by the leading characters 0x or 0X (zero "x"), followed by digits and the characters a-f or A-F, which represent the decimal values 10-15:
int i = 0xFFFF; // i = 65535 decimal
Integer literals are of type int unless they are suffixed with an L , denoting that they are to be produced as a long value:
long l = 13L; long l = 13; // equivalent: 13 is converted from type int
(The lowercase character l ("el") is also acceptable but should be avoided because it often looks like the numeral 1 .)
When a numeric type is used in an assignment or an expression involving a type with a larger range, it can be promoted to the larger type. For example, in the second line of the previous example, the number 13 has the default type of int , but it's promoted to type long for assignment to the long variable. Certain other numeric and comparison operations also cause this kind of arithmetic promotion. A numeric value can never be assigned to a type with a smaller range without an explicit (C-style) cast, however:
int i = 13; byte b = i; // Compile-time error, explicit cast needed byte b = (byte) i; // OK
Conversions from floating-point to integer types always require an explicit cast because of the potential loss of precision.
Floating-point values can be specified in decimal or scientific notation. Floating-point literals are of type double unless they are suffixed with an f or F denoting that they are to be produced as a float value:
double d = 8.31; double e = 3.00e+8; float f = 8.31F; float g = 3.00e+8F;
A literal character value can be specified either as a single-quoted character or as an escaped ASCII or Unicode sequence:
char a = 'a'; char newline = '\n'; char smiley = '\u263a';
In Java, as in other object-oriented languages, you create new complex data types from primitives by creating a class that defines a new type in the language. For instance, if we create a new class called Foo in Java, we are also implicitly creating a new type called Foo . The type of an item governs how it's used and where it's assigned. An item of type Foo can, in general, be assigned to a variable of type Foo or passed as an argument to a method that accepts a Foo value.
In an object-oriented language like Java, a type is not
Primitive types in Java are used and passed "by value." In other words, when a primitive value is assigned or passed as an argument to a method, it's simply
Let's run through an example. We specify a variable of type Foo , called myFoo , and assign it an appropriate object: [2]
Foo myFoo = new Foo( ); Foo anotherFoo = myFoo;
is a reference-type variable that holds a reference to the newly
We can pass an object to a method by specifying a reference-type variable (in this case, either myFoo or anotherFoo ) as the argument:
myMethod( myFoo );
An important, but sometimes confusing, distinction to make at this point is that the reference itself is passed by value. That is, the argument passed to the method (a local variable from the method's point of view) is actually a third copy of the reference. The method can alter the state of the Foo object itself through that reference, but it can't change the caller's notion of the reference to myFoo . That is, the method can't change the caller's myFoo to point to a different Foo object; it can change only its own. For those occasions when we want a method to have the side effect of changing a reference passed to it, we have to wrap that reference in another object to provide a layer of indirection.
Reference types always point to objects, and objects are always defined by classes. However, two special kinds of reference types specify the type of object they point to in a slightly different way. Arrays in Java have a special place in the type system. They are a special kind of object automatically created to hold a series of some other type of object, known as the base type . Declaring an array-type reference implicitly creates the new class type, as you'll see in the next section.
Interfaces are a bit sneakier. An interface defines a set of methods and a corresponding type. Any object that implements all methods of the interface can be treated as an object of that type. Variables and method arguments can be declared to be of interface types, just like class types, and any object that implements the interface can be assigned to them. This allows Java to cross the lines of the class hierarchy in a type-safe way.
Strings in Java are objects; they are therefore a reference type. String objects do, however, have some special help from the Java compiler that makes them look more like primitive types. Literal string values in Java source code are turned into String objects by the compiler. They can be used directly, passed as arguments to methods, or assigned to String type variables:
System.out.println( "Hello World..." ); String s = "I am the walrus..."; String t = "John said: \"I am the walrus...\"";
The + symbol in Java is overloaded to provide string concatenation as well as numeric addition. Along with its sister += , this is the only overloaded operator in Java:
String quote = "Four score and " + "seven years ago,"; String more = quote + " our" + " fathers" + " brought...";
Java builds a single
object from the
Although Java's means of declaring methods is quite different from C++, Java's statement and expression syntax is similar to C. Again, the
One of the tenets of Java is to keep things simple and consistent. To that end, when there are no other constraints, evaluations and initializations in Java always occur in the order in which they appear in the code—from left to right, top to bottom. We'll see this rule used in the evaluation of assignment expressions, method calls, and array indexes, to name a few cases. In some other languages, the order of evaluation is more complicated or even implementation-dependent. Java
As in C or C++, statements and expressions in Java appear within a
code block
. A code block is syntactically a series of statements
{ int size = 5; setName("Max"); ... }
Methods, which look like C functions, are in a sense code blocks that take parameters and can be called by their names, for example, SetUpDog :
setUpDog( String name ) { int size = 5; setName( name ); ... }
Variable declarations are limited in scope to their enclosing code block. That is, they can't be seen outside of the
{ int i = 5; } i = 6; // Compile-time error, no such variable i
In this way, code blocks can be used to arbitrarily group other statements and variables. The most common use of code blocks, however, is to define a
Since a code block is itself collectively treated as a statement, we define a conditional like an
clause as
if ( condition ) statement ; [ else statement ; ]
Thus, the if clause has the familiar (to C/C++ programmers) functionality of taking two different forms. Here's one:
if ( condition ) statement ;
Here's the other:
if ( condition ) { [ statement ; ] [ statement ; ] [ ... ] }
is a boolean expression. You can't use an integer expression or a reference type like you can in C. In other words, while
In the second form, the statement is a code block, and all its
The do and while iterative statements have the familiar functionality; their conditional test is also a boolean expression:
while ( condition ) statement ; do statement ; while ( condition );
The for statement also looks like it does in C:
for ( initialization ; condition ; incrementor ) statement ;
The variable initialization expression can declare a new variable which is then limited to the scope of the for statement:
for (int i = 0; i < 100; i++ ) { System.out.println( i ) int j = i; ... }
Java does not in general support the C comma operator, which groups multiple expressions into a single expression. However, you can use multiple comma-separated expressions in the initialization and increment sections of the for loop. For example:
for (int i = 0, j = 10; i < j; i++, j-- ) { ... }
The Java switch statement takes an integer type (or an argument that can be automatically promoted to an integer type) and selects among a number of alternative case branches:
switch ( int expression ) { case int expression : statement ; [ case int expression statement ; ... default : statement ; ] }
No two of the case expressions can evaluate to the same value. As in C, an optional default case can be specified to catch unmatched conditions. Normally, the special statement break is used to terminate a branch of the switch :
switch ( retVal ) { case myClass.GOOD : // something good break; case myClass.BAD : // something bad break; default : // neither one break; }
The Java
statement and its friend
perform unconditional
one: while ( condition ) { ... two: while ( condition ) { ... // break or continue point } // after two } // after one
In this example, a break or continue without argument at the indicated position would have the normal, C-style effect. A break would cause processing to resume at the point labeled "after two"; a continue would immediately cause the two loop to return to its condition test.
The statement break two at the indicated point would have the same effect as an ordinary break , but break one would break both levels and resume at the point labeled "after one." Similarly, continue two would serve as a normal continue , but continue one would return to the test of the one loop. Multilevel break and continue statements remove the remaining justification for the evil goto statement in C/C++.
There are a few Java statements we aren't going to discuss right now. The try , catch , and finally statements are used in exception handling, as we'll discuss later in this chapter. The synchronized statement in Java is used to coordinate access to statements among multiple threads of execution; see Chapter 8 for a discussion of thread synchronization.
On a final note, we should mention that the Java compiler flags "unreachable" statements as compile-time errors. An unreachable statement is one that the compiler determines won't be called at all. Of course there may be many methods that are actually never called in your code, but the compiler detects only those that it can "
if (1 < 2) return; // unreachable statements
An expression produces a result, or value, when it is evaluated. The value of an expression can be a numeric type, as in an arithmetic expression; a reference type, as in an object allocation; or the special type void , which is the declared type of a method that doesn't return a value. In the last case, the expression is evaluated only for its side effects , that is, the work it does aside from producing a value. The type of an expression is known at compile time. The value produced at runtime is either of this type or, in the case of a reference type, a compatible (assignable) subtype.
Java supports almost all standard C operators. These operators also have the same precedence in Java as they do in C, as shown in Table 4-3.
Precedence |
Operator |
Operand type |
Description |
1 |
++, -- |
Arithmetic |
Increment and decrement |
1 |
+, - |
Arithmetic |
Unary plus and minus |
1 |
~ |
Integral |
Bitwise complement |
1 |
! |
Boolean |
Logical complement |
1 |
( type ) |
Any |
Cast |
2 |
*, /, % |
Arithmetic |
Multiplication, division, remainder |
3 |
+, - |
Arithmetic |
Addition and subtraction |
3 |
+ |
String |
String concatenation |
4 |
<< |
Integral |
Left shift |
4 |
>> |
Integral |
Right shift with sign extension |
4 |
>>> |
Integral |
Right shift with no extension |
5 |
<, <=, >, >= |
Arithmetic |
Numeric comparison |
5 |
instanceof |
Object |
Type comparison |
6 |
==, != |
Primitive |
Equality and inequality of value |
6 |
==, != |
Object |
Equality and inequality of reference |
7 |
& |
Integral |
Bitwise AND |
7 |
& |
Boolean |
Boolean AND |
8 |
^ |
Integral |
Bitwise XOR |
8 |
^ |
Boolean |
Boolean XOR |
9 |
Integral |
Bitwise OR |
9 |
Boolean |
Boolean OR |
10 |
&& |
Boolean |
Conditional AND |
11 |
Boolean |
Conditional OR |
12 |
?: |
Conditional ternary operator |
13 |
= |
Any |
Assignment |
13 |
*=, /=, %=, +=, -=, <<=, >> =, >>>=, &=, ^=, = |
Any |
Assignment with operation |
There are a few operators missing from the standard C collection. As we said, Java doesn't support the comma operator for combining expressions, although the for statement allows you to use it in the initialization and increment sections. Java doesn't allow direct pointer manipulation, so it doesn't support the reference ( & ), dereference ( * ), and sizeof operators that are familiar to C/C++ programmers. We should also note that the percent (%) operator is not strictly a modulo, but a remainder, and it can have a negative value.
Java also adds some new operators. As we've seen, the
operator can be used with
values to perform string concatenation. Because all integral types in Java are signed values, the
While variable initialization (i.e., declaration and assignment together) is considered a statement, with no resulting value, variable assignment alone is also an expression:
int i, j; // statement i = 5; // both expression and statement
Normally, we rely on assignment for its side effects alone, but, as in C, an assignment can be used as a value in another part of an expression:
j = ( i = 5 );
Again, relying on order of evaluation extensively (in this case, using compound assignments in complex expressions) can make code very obscure and hard to read. Do so at your own peril.
The expression null can be assigned to any reference type. It has the meaning of "no reference." A null reference can't be used to reference anything and attempting to do so generates a NullPointerException at runtime.
The dot ( . ) operator has multiple meanings. It can retrieve the value of an instance variable (of some object) or a static variable (of some class). It can also specify a method to be invoked on an object or class. Using the dot ( . ) to access a variable in an object is an expression that results in the value of the variable accessed. This can be either a numeric type or a reference type:
int i; String s; i = myObject.length; s = myObject.name;
A reference-type expression can be used in further evaluations, by selecting variables or calling methods within it:
int len = myObject.name.length( ); int initialLen = myObject.name.substring(5, 10).length( );
Here we have found the length of our name variable by invoking the length() method of the String object. In the second case, we took an intermediate step and asked for a substring of the name string. The substring method of the String class also returns a String reference, for which we ask the length. Compounding operations like this is also called "chaining," which we'll mention again later.
A method invocation is
System.out.println( "Hello World..." ); int myLength = myString.length( );
Here we invoked the methods println() and length() on different objects. Selecting which method is invoked, however, can be more complicated than it appears, because Java allows method overloading and overriding (multiple methods with the same name); the details are discussed in Chapter 5.
Like the result of any expression, the result of a method invocation can be used in further evaluations, as we saw earlier. You can allocate intermediate variables to make it absolutely clear what your code is doing, or you can opt for brevity where appropriate; it's all a matter of coding style. The two following code snippets are equivalent:
int initialLen = myObject.name.substring(5, 10).length( ); String temp1 = myObject.name; String temp2 = temp1.substring(5, 10); int initialLen = temp2.length( );
Objects in Java are allocated with the new operator:
Object o = new Object( );
The argument to new is the constructor for the class. The constructor is a method that always has the same name as the class. The constructor specifies any required parameters to create an instance of the object. The value of the new expression is a reference of the type of the created object. Objects always have one or more constructors, though they may not always be accessible to you.
We'll look at object creation in detail in Chapter 5. For now, just note that object creation is a type of expression and that the resulting object reference can be used in general expressions. In fact, because the binding of new is "tighter" than that of dot ( . ), you can easily create a new object and invoke a method in it, without assigning the object to a reference type variable:
int hours = new Date( ).getHours( );
class is a utility class that represents the current time. Here we create a new instance of
with the
operator and call its
method to retrieve the current
Calling methods in object references in this way is, again, a matter of style. It would
operator can be used to determine the type of an object at runtime. It
Boolean b; String str = "foo"; b = ( str instanceof String ); // true b = ( str instanceof Object ); // also true b = ( str instanceof Date ); // false, not a Date or subclass
also correctly
if ( foo instanceof byte[] ) ...
It is also important to note that the value null is not considered an instance of any object. So the following test returns false , no matter what the declared type of the variable:
String s = null; if ( s instanceof String ) // false, won't happen
Java's roots are in embedded systems—software that runs inside specialized devices such as hand-held computers, cellular phones, and fancy toasters. In those kinds of applications, it's
Dealing with errors in a language such as C is entirely the responsibility of the programmer. There is no help from the language itself in identifying error types, and there are no tools for dealing with them easily. In C, a routine
Java offers an elegant solution to these problems through exceptions . (Java exception handling is similar to, but not quite the same as, exception handling in C++.) An exception indicates an unusual condition or an error condition. Program control becomes unconditionally transferred or "thrown" to a specially designated section of code where it's caught and handled. In this way, error handling is orthogonal to (or outside) the normal flow of the program. We don't have to have special return values for all our methods; errors are handled by a separate mechanism. Control can be passed long distance from a deeply nested routine and handled in a single location when that is desirable, or an error can be handled immediately at its source. There are still some standard methods that return -1 as a special value, but these are generally limited to situations where we are expecting a special value. [4]
A Java method is required to specify the exceptions it can throw (i.e., the ones that it doesn't catch itself); this means that the compiler can make sure we handle them. In this way, the information about what errors a method can produce is promoted to the same level of importance as its argument and return types. You may still decide to punt and ignore obvious errors, but in Java you must do so explicitly.
Exceptions are represented by instances of the class java.lang.Exception and its subclasses. Subclasses of Exception can hold specialized information (and possibly behavior) for different kinds of exceptional conditions. However, more often they are simply "logical" subclasses that serve only to identify a new exception type. Figure 4-1 shows the subclasses of Exception in the java.lang package. It should give you a feel for how exceptions are organized. Most other packages define their own exception types, which usually are subclasses of Exception itself or of its important subclass RuntimeException .
Another important exception class is IOException in the package java.io . The IOException class has many subclasses for typical I/O problems (such as FileNotFoundException ) and networking problems (such as MalformedURLException ). Network exceptions belong to the java.net package. Another important descendant of IOException is RemoteException , which belongs to the java.rmi package. It is used when problems arise during remote method invocation (RMI). Throughout this book we'll mention the exceptions you need to be aware of as we run into them.
An Exception object is created by the code at the point where the error condition arises. It can be designed to hold whatever information is necessary to describe the exceptional condition and also includes a full stack trace for debugging. (A stack trace is the list of all the methods called in order to reach the point where the exception was thrown). The Exception object is passed as an argument to the handling block of code, along with the flow of control. This is where the terms "throw" and "catch" come from: the Exception object is thrown from one point in the code and caught by the other, where execution resumes.
The Java API also defines the
class for unrecoverable errors. The subclasses of
in the
package are shown in Figure 4-2. A notable
type is
, which is used by the Java assert language statement to
Both Exception and Error are subclasses of Throwable . Throwable is the base class for objects which can be "thrown" with the Java language throw statement. In general you should extend only Exception , Error or one of their subclasses.
The try/catch guarding statements wrap a block of code and catch designated types of exceptions that occur within it.
try { readFromFile("foo"); ... } catch ( Exception e ) { // Handle error System.out.println( "Exception while reading file: " + e ); ... }
In this example, exceptions that occur within the body of the try portion of the statement are directed to the catch clause for possible handling. The catch clause acts like a method; it specifies an argument of the type of exception it wants to handle and, if it's invoked, it receives the Exception object as an argument. Here we receive the object in the variable e and print it along with a message.
A try statement can have multiple catch clauses that specify different types (subclasses) of Exception :
try { readFromFile("foo"); ... } catch ( FileNotFoundException e ) { // Handle file not found ... } catch ( IOException e ) { // Handle read error ... } catch ( Exception e ) { // Handle all other errors ... }
The catch clauses are evaluated in order, and the first possible (assignable) match is taken. At most, one catch clause is executed, which means that the exceptions should be listed from most specific to least. In the previous example, we'll anticipate that the hypothetical readFromFile() can throw two different kinds of exceptions: one for a file not found and another for a more general read error. Any subclass of Exception is assignable to the parent type Exception , so the third catch clause acts like the default clause in a switch statement and handles any remaining possibilities.
One beauty of the
scheme is that any statement in the
block can assume that all previous statements in the block succeeded. A problem won't arise suddenly because a programmer
What if we hadn't caught the exception? Where would it have gone? Well, if there is no enclosing
statement, the exception pops to the top of the method in which it appeared and is, in
Let's look at another example. In Figure 4-3, the method getContent() invokes the method openConnection() from within a try/catch statement. In turn, openConnection() invokes the method sendRequest() , which calls the method write() to send some data.
In this figure, the second call to write() throws an IOException . Since sendRequest() doesn't contain a try/catch statement to handle the exception, it's thrown again from the point where it was called in the method openConnection() . Since openConnection() doesn't catch the exception either, it's thrown once more. Finally it's caught by the try statement in getContent() and handled by its catch clause.
Since an exception can bubble up quite a distance before it is caught and handled, we may need a way to determine exactly where it was thrown. All exceptions can dump a
stack trace
that lists their method of origin and all the nested method calls it took to
try { // complex task } catch ( Exception e ) { // dump information about exactly where the exception occurred e.printStackTrace( System.err ); ... }
Java 1.4 introduces methods that allow you to retrieve the stack trace information programmatically, using the Throwable getStackTrace() method. This method returns an array of StackTraceElement objects, each of which represents a method call on the stack. You can ask a StackTraceElement for details about that method's location using the methods getFileName() , getClassName() , getMethodName() , and getLineNumber() .
We explained earlier how Java forces us to be explicit about our error handling. But it's not realistic to require that every conceivable type of error be handled in every situation. So Java exceptions are divided into two categories: checked and unchecked . Most application-level exceptions are checked, which means that any method that throws one, either by generating it itself (as we'll discuss later) or by ignoring one that occurs within it, must declare that it can throw that type of exception in a special throws clause in its method declaration. We haven't yet talked in detail about declaring methods; we'll cover that in Chapter 5. For now all you need to know is that methods have to declare the checked exceptions they can throw or allow to be thrown.
Again in Figure 4-3, notice that the methods openConnection() and sendRequest() both specify that they can throw an IOException . If we had to throw multiple types of exceptions, we could declare them separated with commas:
void readFile( String s ) throws IOException, InterruptedException { ... }
In contrast, exceptions that are subclasses of either the class java.lang. RuntimeException or the class java.lang.Error are unchecked. See Figure 4-1 for the subclasses of RuntimeException . (Subclasses of Error are generally reserved for serious class loading or runtime system problems.) It's not a compile-time error to ignore the possibility of these exceptions; methods don't have to declare they can throw them. In all other respects, unchecked exceptions behave the same as other exceptions. We are free to catch them if we wish; we simply aren't required to.
Checked exceptions are intended to cover application-level problems such as missing files and unavailable
To sum up, checked exceptions are problems a reasonable application should try to handle gracefully; unchecked exceptions (runtime exceptions or errors) are problems from which we would not normally expect our software to recover. Error types are those explicitly intended to be conditions that we should never try to handle or recover from.
We can throw our own exceptions: either instances of Exception or one of its existing subclasses, or our own specialized exception classes. All we have to do is create an instance of the Exception and throw it with the throw statement:
throw new Exception( );
Execution stops and is transferred to the nearest enclosing try/catch statement. (There is little point in keeping a reference to the Exception object we've created here.) An alternative constructor lets us specify a string with an error message:
throw new Exception("Something really bad happened");
You can retrieve this string by using the Exception object's getMessage() method. Often, though, you can just refer to the object itself; in the first example in the earlier section, Section 4.5.2, an exception's string value is automatically provided to the println() method.
By convention, all types of Exception have a String constructor like this. The earlier String message is somewhat facetious and vague. Normally you won't be throwing a plain old Exception but a more specific subclass. For example:
public void checkRead( String s ) { if ( new File(s).isAbsolute( ) (s.indexOf("..") != -1) ) throw new SecurityException( "Access to file : "+ s +" denied."); }
In this code, we partially implement a method to check for an illegal path. If we find one, we throw a SecurityException , with some information about the transgression.
Of course, we could include whatever other information is useful in our own specialized subclasses of Exception . Often, though, just having a new type of exception is good enough because it's sufficient to help direct the flow of control. For example, if we are building a parser, we might want to make our own kind of exception to indicate a particular kind of failure:
class ParseException extends Exception { ParseException( ) { super( ); } ParseException( String desc ) { super( desc ); } }
See Chapter 5 for a full description of classes and class constructors. The body of our Exception class here simply allows a ParseException to be created in the conventional ways we've created exceptions previously (either generically or with a simple string description). Now that we have our new exception type, we can guard like so:
// Somewhere in our code ... try { parseStream( input ); } catch ( ParseException pe ) { // Bad input... } catch ( IOException ioe ) { // Low-level communications problem }
As you can see, although our new exception doesn't currently hold any specialized information about the problem (it certainly could), it does let us distinguish a parse error from an arbitrary I/O error in the same
Sometimes you'll want to take some action based on an exception and then turn around and throw a new exception in its place. This is common when building frameworks, where low-level detailed exceptions are handled and represented by higher level exceptions that can be managed more easily. For example you might want to catch an IOException in a communication package, possibly perform some cleanup, and ultimately throw a higher level exception of your own, maybe something like LostServerConnection .
You can do this in the obvious way by simply catching the exception and then throwing a new one. But then you lose important information, including the stack trace of the original "
throw new Exception( "Here's the story...", causalException );
You can get access to this exception later with the getCause() method, which returns the causal exception. More importantly, Java automatically prints both exceptions and their respective stack traces if you print the exception or if it is shown to the user.
You can add this kind of constructor to your own exception subclasses as well (delegating to the parent constructor). However, since this is (at least
Try { // ... } catch ( IOException cause ) { Exception e = new IOException("What we have here is a failure to communicate..."); e.initCause( cause ); throw e; }
statement imposes a condition on the statements that it
void myMethod( ) { int foo; try { foo = getResults( ); } catch ( Exception e ) { ... } int bar = foo; // Compile-time error -- foo may not have been initialized
In this example, we can't use foo in the indicated place because there's a chance it was never assigned a value. One obvious option is to move the assignment inside the try statement:
try { foo = getResults( ); int bar = foo; // Okay because we get here only // if previous assignment succeeds } catch ( Exception e ) { ... }
Sometimes this works just fine. However, now we have the same problem if we want to use bar later in myMethod() . If we're not careful, we might end up pulling everything into the try statement. The situation changes if we transfer control out of the method in the catch clause:
try { foo = getResults( ); } catch ( Exception e ) { ... return; } int bar = foo; // Okay because we get here only // if previous assignment succeeds
The compiler is smart enough to know that if an error had occurred in the try clause we wouldn't have reached the bar assignment. Your code will
What if we have some cleanup to do before we exit our method from one of the
clauses? To avoid duplicating the code in each
branch and to make the cleanup more explicit, use the
clause. A
clause can be added after a
and any associated
clauses. Any statements in the body of the
clause are
try { // Do something here } catch ( FileNotFoundException e ) { ... } catch ( IOException e ) { ... } catch ( Exception e ) { ... } finally { // Clean up here }
In this example, the statements at the cleanup point are executed eventually, no matter how control leaves the try . If control transfers to one of the catch clauses, the statements in finally are executed after the catch completes. If none of the catch clauses handles the exception, the finally statements are executed before the exception propagates to the next level.
If the statements in the try execute cleanly, or if we perform a return , break , or continue , the statements in the finally clause are executed. To perform cleanup operations, we can even use try and finally without any catch clauses:
try { // Do something here return; } finally { System.out.println("Whoo-hoo!"); }
Exceptions that occur in a catch or finally clause are handled normally; the search for an enclosing try/catch begins outside the offending try statement.
We mentioned at the beginning of this section that there are methods in the
But there is also a performance issue. Because of the way the Java virtual machine is implemented, guarding against an exception being thrown (using a
) is free. It doesn't add any overhead to the execution of your code. However, throwing an exception is not free. When an exception is thrown, Java has to locate the appropriate
block and perform other
The result is that you should throw exceptions only in truly "exceptional" circumstances and try to avoid using them for expected conditions, especially when performance is an issue. For example, if you have a loop, it may be better to perform a small test on each pass and avoid throwing the exception, rather than throwing it frequently. On the other hand, if the exception is thrown only one in a gazillion times, you may want to eliminate the overhead of the test code and not worry about the cost of throwing that exception.
An assertion is a simple pass/fail test of some condition, performed while your application is running. Assertions can be used to check the "
Using assertions to test for the correct behavior of your application is a simple but powerful technique for ensuring software quality. It fills a gap between those aspects of software that can be checked automatically by the compiler and those more generally checked by "unit tests" and human testing. Assertions test assumptions about program behavior and make them
Explicit support for assertions was added in Java 1.4. However, if you've written much code in any language, you have probably used assertions in some form. For example, you may have written something like the following:
if ( !condition ) throw new AssertionError("fatal error: 42");
An assertion in Java is equivalent to this example but performed with the assert language keyword. It takes a boolean condition and an optional expression value. If the assertion fails, an AssertionError is thrown, which usually causes Java to bail out of the application.
The optional expression may evaluate to either a primitive or object type. Either way, its sole purpose is to be turned into a string and shown to the user if the assertion fails; most often you'll use a string message explicitly. Here are some examples:
assert false; assert ( array.length > min ); assert a > 0 : a assert foo != null : "foo is not null!"
In the event of failure, the first two assertions print only a generic message whereas the third prints the value of a and the last prints the foo is not null! message.
Again, the important thing about assertions is not just that they are more terse than the equivalent if condition but that they can be enabled or disabled when you run the application. Disabling assertions means that their test conditions are not even evaluated, so there is no performance penalty for including them in your code (other than, perhaps, space in the class files when they are loaded).
Assertions are supported only in Java 1.4 and (for now) require passing a special switch to the compiler so it recognizes the assert keyword. So to use the assert examples, you'll have to compile using the -source compiler switch and specify 1.4 as the language version. For example:
% javac -source 1.4 MyApplication.java
Assertions were implemented this way to provide some migration time for existing applications with their own methods named assert , which will now be illegal. In some future release, assertions will be recognized by default.
Assertions are turned on or off at runtime. When disabled, assertions still exist in the class files but are not executed and
% java -ea MyApplication
To turn on assertions for a particular class, append the class name like so:
% java -ea:com.oreilly.examples.Myclass
To turn on assertions just for particular packages append the package name with trailing ellipses (three dots) like so:
% java -ea:com.oreilly.examples...
When you enable assertions for package, Java also enables all subordinate package names (e.g., com.oreilly.examples.text ). However you can become more selective by using the corresponding -da or -disableassertions flag to negate individual packages or classes. You can combine all this to achieve arbitrary groupings like this:
% java -ea:com.oreilly.examples... -da:com.oreilly.examples.text -ea:com.oreilly.examples.text.MonkeyTypewriters MyApplication
This example enables assertions for the com.oreilly.examples package as a whole, excludes the package com.oreilly.examples.text , then turns exceptions on for just one class, MonkeyTypewriters , in that package.
An assertion enforces a rule about something that should be unchanging in your code and would otherwise go unchecked. You can use an assertion for added safety anywhere you want to verify your assumptions about program behavior that can't be checked by the compiler.
A common situation that cries out for an assertion is testing for multiple conditions or values where one should always be found. In this case, a failing assertion as the default or "fall through" behavior indicates the code is broken. For example, suppose we have a value called direction that should always contain either the constant value LEFT or RIGHT :
if ( direction == LEFT ) doLeft( ); else if ( direction == RIGHT ) doRight( ) else assert false : "bad direction";
The same applies to the default case of a switch:
switch ( direction ) { case LEFT: doLeft( ); break; case RIGHT: doRight( ); break; default: assert false; }
In general, you should not use assertions for checking the validity of arguments to methods because you want that behavior to be part of your application, not just a test for quality control that can be turned off. The validity of input to a method is called its pre-conditions, and you should usually throw an exception if they are not met; this elevates the preconditions to part of the method's "contract" with the user. However, checking the results of your methods before returning them is always valid; these are called post-conditions .
Sometimes determining what is or is not a pre-condition depends on your point of view. For example, when a method is used internally within a class, pre-conditions may already be guaranteed by the methods that call it. Public methods of the class should probably throw exceptions when their pre-conditions are violated, but a private method might use assertions because its
Finally, note that assertions can not only test simple expressions but perform complex validation as well. Remember that anything you place in the condition expression of an assert statement is not evaluated when assertions are turned off. You can make helper methods for your assertions, containing arbitrary amounts of code. And, although it suggests a dangerous programming style, you can even use assertions that have side effects to capture values for use by later assertions—all of which will be disabled when assertions are turned off. For example:
int savedValue; assert ( savedValue = getValue( )) != -1; // Do work... assert checkValue( savedValue );
Here, in the first assert, we use helper method getValue() to retrieve some information and save it for later. Then after doing some work, we check the saved value using another assertion, perhaps comparing results. When assertions are disabled we'll no longer save or check the data. Note that it's necessary for us to be somewhat cute and make our first assert condition into a boolean by checking for a known value. Again, using assertions with side effects is a bit dangerous because you have to be careful that those side effects are only seen by other assertions. Otherwise, you'll be changing your application behavior when you turn them off.
An array is a special type of object that can hold an ordered collection of elements. The type of the elements of the array is called the base type of the array; the number of elements it holds is a fixed attribute called its length . Java supports arrays of all primitive and reference types.
The basic syntax of arrays looks much like that of C or C++. We create an array of a specified length and access the elements with the index operator, [] . Unlike other languages, however, arrays in Java are true, first-class objects. An array is an instance of a special Java array class and has a corresponding type in the type system. This means that to use an array, as with any other object, we first declare a variable of the appropriate type and then use the new operator to create an instance of it.
Array objects differ from other objects in Java in three respects:
Java implicitly creates a special array class type for us whenever we declare an array type variable. It's not strictly necessary to know about this process in order to use arrays, but it helps in understanding their structure and their relationship to other objects in Java.
Java lets us use the
operator to access array elements, so that arrays look as we expect. We could implement our own classes that act like arrays, but we would have to
Java provides a corresponding special form of the new operator that lets us construct an instance of an array and specify its length with the [] notation or initialize it from a structured list of values.
An array-type variable is denoted by a base type followed by the empty brackets, [] . Alternatively, Java accepts a C-style declaration, with the brackets placed after the array name.
The following are equivalent:
int [] arrayOfInts; int arrayOfInts [];
In each case, arrayOfInts is declared as an array of integers. The size of the array is not yet an issue, because we are declaring only the array-type variable. We have not yet created an actual instance of the array class, with its associated storage. It's not even possible to specify the length of an array when declaring an array-type variable.
An array of objects can be created in the same way:
String [] someStrings; Button someButtons [];
The new operator is used to create an instance of an array. After the new operator, we specify the base type of the array and its length, with a bracketed integer expression:
arrayOfInts = new int [42]; someStrings = new String [ number + 2 ];
We can, of course, combine the steps of declaring and allocating the array:
double [] someNumbers = new double [20]; Component widgets [] = new Component [12];
As in C, array indices start with zero. Thus, the first element of someNumbers[] is , and the last element is 19 . After creation, the array elements are initialized to the default values for their type. For numeric types, this means the elements are initially zero:
int [] grades = new int [30]; grades[0] = 99; grades[1] = 72; // grades[2] == 0
The elements of an array of objects are references to the objects, not actual instances of the objects. The default value of each element is therefore null , until we assign instances of appropriate objects:
String names [] = new String [4]; names [0] = new String( ); names [1] = "Boofa"; names [2] = someObject.toString( ); // names[3] == null
This is an important distinction that can cause confusion. In many other languages, the act of creating an array is the same as allocating storage for its elements. In Java, a newly allocated array of objects actually contains only reference variables, each with the value null . [5] That's not to say that there is no memory associated with an empty array; there is memory needed to hold those references (the empty "slots" in the array). Figure 4-4 illustrates the names array of the previous example.
names is a variable of type String[] (i.e., a string array). This particular String[] object contains four String type variables. We have assigned String objects to the first three array elements. The fourth has the default value null .
Java supports the C-style curly braces {} construct for creating an array and initializing its elements:
int [] primes = { 1, 2, 3, 5, 7, 7+4 }; // primes[2] == 3
An array object of the proper type and length is implicitly created, and the values of the comma-separated list of expressions are assigned to its elements.
We can use the {} syntax with an array of objects. In this case, each expression must evaluate to an object that can be assigned to a variable of the base type of the array, or the value null . Here are some examples:
String [] verbs = { "run", "jump", someWord.toString( ) }; Button [] controls = { stopButton, new Button("Forwards"), new Button("Backwards") }; // All types are subtypes of Object Object [] objects = { stopButton, "A word", null };
The following are equivalent:
Button [] threeButtons = new Button [3]; Button [] threeButtons = { null, null, null };
The size of an array object is available in the public variable length :
char [] alphabet = new char [26]; int alphaLen = alphabet.length; // alphaLen == 26 String [] musketeers = { "one", "two", "three" }; int num = musketeers.length; // num == 3
is the only accessible field of an array; it is a variable, not a method. (Don't worry, the compiler tells you when you
Array access in Java is just like array access in C; you access an element by
Button [] keyPad = new Button [ 10 ]; for ( int i=0; i < keyPad.length; i++ ) keyPad[ i ] = new Button( Integer.toString( i ) );
Attempting to access an element that is outside the range of the array generates an ArrayIndexOutOfBoundsException . This is a type of RuntimeException , so you can either catch and handle it yourself, if you really expect it, or ignore it, as we've already discussed:
String [] states = new String [50]; try { states[0] = "California"; states[1] = "Oregon"; ... states[50] = "McDonald's Land"; // Error: array out of bounds } catch ( ArrayIndexOutOfBoundsException err ) { System.out.println( "Handled error: " + err.getMessage( ) ); }
It's a common task to copy a range of elements from one array into another. Java
The following example doubles the size of the names array from an earlier example:
String [] tmpVar = new String [ 2 * names.length ]; System.arraycopy( names, 0, tmpVar, 0, names.length ); names = tmpVar;
A new array, twice the size of names , is allocated and assigned to a temporary variable tmpVar . The arraycopy() method is then used to copy the elements of names to the new array. Finally, the new array is assigned to names . If there are no remaining references to the old array object after names has been copied, it is garbage-collected on the next pass.
Often it is
Let's say you need to call a method named setPets() , which takes an array of Animal objects as arguments. Provided Cat and Dog are subclasses of Animal , here's how to call setPets() using an anonymous array:
Dog pokey = new Dog ("gray"); Cat boojum = new Cat ("grey"); Cat simon = new Cat ("orange"); setPets ( new Animal [] { pokey, boojum, simon });
The syntax looks just like the initialization of an array in a variable declaration. We implicitly define the size of the array and fill in its elements using the curly-brace notation. However, since this is not a variable declaration, we have to explicitly use the new operator to create the array object.
You can use anonymous arrays to simulate variable-length argument lists (called VARARGS in C), a feature of many programming languages that Java doesn't provide. The advantage of anonymous arrays over variable-length argument lists is that the former allow stricter type checking; the compiler always
Java supports multidimensional arrays in the form of arrays of array type objects. You create a multidimensional array with C-like syntax, using multiple
ChessPiece [][] chessBoard; chessBoard = new ChessPiece [8][8]; chessBoard[0][0] = new ChessPiece( "Rook" ); chessBoard[1][0] = new ChessPiece( "Pawn" ); ...
is declared as a variable of type
(i.e., an array of
arrays). This declaration implicitly creates the type
as well. The example illustrates the special form of the
operator used to create a multidimensional array. It creates an array of
objects and then, in turn, makes each element into an array of
objects. We then index
to specify values for particular
elements. (We'll neglect the
Of course, you can create arrays with more than two dimensions. Here's a slightly
Color [][][] rgbCube = new Color [256][256][256]; rgbCube[0][0][0] = Color.black; rgbCube[255][255][0] = Color.yellow; ...
As in C, we can specify a partial index of a multidimensional array to get an array-type object with fewer dimensions. In our example, the variable chessBoard is of type ChessPiece[][] . The expression chessBoard[0] is valid and refers to the first element of chessBoard , which, in Java, is of type ChessPiece[] . For example, we can create a row for our chess board:
ChessPiece [] startRow = { new ChessPiece("Rook"), new ChessPiece("Knight"), new ChessPiece("Bishop"), new ChessPiece("King"), new ChessPiece("Queen"), new ChessPiece("Bishop"), new ChessPiece("Knight"), new ChessPiece("Rook") }; chessBoard[0] = startRow;
We don't necessarily have to specify the dimension sizes of a multidimensional array with a single new operation. The syntax of the new operator lets us leave the sizes of some dimensions unspecified. The size of at least the first dimension (the most significant dimension of the array) has to be specified, but the sizes of any number of trailing, less significant array dimensions may be left undefined. We can assign appropriate array-type values later.
We can create a checkerboard of boolean values (which is not quite sufficient for a real game of checkers) using this technique:
boolean [][] checkerBoard; checkerBoard = new boolean [8][];
Here, checkerBoard is declared and created, but its elements, the eight boolean[] objects of the next level, are left empty. Thus, for example, checkerBoard[0] is null until we explicitly create an array and assign it, as follows:
checkerBoard[0] = new boolean [8]; checkerBoard[1] = new boolean [8]; ... checkerBoard[7] = new boolean [8];
The code of the previous two examples is equivalent to:
boolean [][] checkerBoard = new boolean [8][8];
One reason we might want to leave dimensions of an array unspecified is so that we can store arrays given to us by another method.
Note that since the length of the array is not part of its type, the arrays in the checkerboard do not necessarily have to be of the same length. That is, multidimensional arrays don't have to be rectangular. Here's a defective (but
checkerBoard[2] = new boolean [3]; checkerBoard[3] = new boolean [10];
And here's how you could create and initialize a
int [][] triangle = new int [5][]; for (int i = 0; i < triangle.length; i++) { triangle[i] = new int [i + 1]; for (int j = 0; j < i + 1; j++) triangle[i][j] = i + j; }
We said earlier that arrays are instances of special array classes in the Java language. If arrays have classes, where do they fit into the class hierarchy and how are they related? These are good questions; however, we need to talk more about the object-oriented aspects of Java before answering them. That's the subject of the next chapter. For now, take it on faith that arrays fit into the class hierarchy.
[1] For more information about Unicode, see http://www.unicode.org. Ironically, one of the scripts listed as "obsolete and archaic" and not currently supported by the Unicode standard is Javanese—a historical language of the people of the Island of Java.
[2] The comparable code in C++ would be:
[3] The somewhat obscure setjmp( ) and longjmp( ) statements in C can save a point in the execution of code and later return to it unconditionally from a deeply buried location. In a limited sense, this is the functionality of exceptions in Java.
[4] For example, the getHeight( ) method of the Image class returns -1 if the height isn't known yet. No error has occurred; the height will be available in the future. In this situation, throwing an exception would be inappropriate.
[5] The analog in C or C++ is an array of pointers to objects. However, pointers in C or C++ are themselves two- or four-byte values. Allocating an array of pointers is, in actuality, allocating the storage for some number of those pointer objects. An array of references is conceptually similar, although references are not
themselves objects. We can't manipulate references orparts of references other than by assignment, and their storage requirements (or lack thereof) are not part of the high-level Java language specification.


text:
SLTD Radio is BACK! Episode 2 – LIVE! June 20th
Fight Club Pro
Coming Soon – SLTV
Follow me on Twitter
My TweetsUpcoming
Like us on Facebook
Blog Authors
Sponsors & Partners
Recent Comments
- Jorge Soares on Could Bill Goldberg Be Making A Return To WWE?
- Raw Revisited 17th June: A Lot Left In The Tank on Paybacks A Bitch… To Watch… At Times
- This Week on SLTD Wrestling – June 8th to June 16th on Duckman Previews WWE Payback.
- This Week on SLTD Wrestling – June 8th to June 16th on Raw Revisited 10th June: For Whom The Bell Trolls
- This Week on SLTD Wrestling – June 8th to June 16th on Smoke & Mirrors: Slammiversary Thoughts and My State of TNA Address
Search Results
Sorry, we couldn't find any results based on your search query.
Blog Archive
Raw Revisited 17th June: A Lot Left In The Tank
Posted on June 19, 2013 | No CommentsBonjour, Bongiourno, Guten Tag and Hello. Welcome to the latest Raw Revisited, where I dissect Raw and make a lot of over-the-top comments about HHH because he's HHH. Even when... -
This Week In TNA – 13/06/13
Posted on June 19, 2013 | No CommentsTNA comes from Atlanta, Georgia again this week. Last week, Impact was live, but this was a pre-recorded episode, which is the way TNA are running while they're on the... -
Paybacks A Bitch… To Watch… At Times
Posted on June 18, 2013 | 1 CommentHello ladies, gentlemen and wildlife. Welcome to my recap of WWE's inaugural Payback PPV. I admire the WWE's attempts to create new and exciting names for PPVs to drum up... -
This Week on SLTD Wrestling – June 8th to June 16th
Posted on June 16, 2013 | No CommentsIt's been a busy week on the site once again this week, with plenty of new blogs posted and a whole lot of predictions posts ahead of WWE Payback tonight!... -
Under the Spotlight – The WWE App
Posted on June 16, 2013 | No CommentsHey, everyone! I'm Adam O'Brien, welcoming you all to 'Under the Spotlight'. You're lucky that I've been able to write this, considering I've been glued to Naughty Dog's latest gaming masterpiece,... -
My Raw Review & Payback Predictions
Posted on June 15, 2013 | No CommentsHappy Saturday and hello peeps. It's that time of week again where I blog/write about WWE. This week, I'm bringing you my review of the latest episode of Monday Night... -
Duckman Previews WWE Payback.
Posted on June 15, 2013 | 1 CommentAlright you crazy kids, stop sniffing glue and harassing celebrities on Twitter, or whatever it is you young whippersnappers do for fun these days. It's time for a good old... -
SLTD Wrestling PPV Predictions – WWE Payback 2013
Posted on June 14, 2013 | No CommentsWelcome along to the latest round of SLTD Wrestling's PPV Predictions. Let's take care of some business first. In case you missed it last time around, we announced some major... -
AOB's WWE Payback Predictions
Posted on June 14, 2013 | 1 CommentHello boys and girls! My name is Adam O'Brien, and I welcome you all to my predictions for WWE Payback! Just in case you didn't know, the event takes place this... -
Davies Dungeon: Size Doesn't Matter
Posted on June 13, 2013 | No CommentsWelcome to the dungeon! Remember the days when the WWF/E was all about giants running the show? It seemed like anyone who was in the main-event had to be over... -
ATH Throwback Thursday – Raven Crucifies The Sandman
Posted on June 13, 2013 | No CommentsIt's Thursday, which means it's time once again for my weekly throwback to the past! In case you've missed it before, or you're a new reader, Throwback Thursday is a... -
Raw Revisited 10th June: For Whom The Bell Trolls
Posted on June 12, 2013 | 1 CommentWelcome back to the Funhouse. I feel like I shouldn't really call it the funhouse when most of these have been primarily angry and hostile. But I will try and...

subset: commoncrawl


text:
Stray Cat Theatre to Present SONS OF THE PROPHET, 2/15-3/2
Back to the Articleby BWW News Desk
Stray Cat Theatre presents the Pulitzer Prize finalist Sons of the Prophet, written by Stephen Karam and directed by Ron May. Their tragedy. Your comedy. Hailed as one of the Top 10 Plays of 2011 from The New York Times, New York Magazine, and Newsday. Stray Cat scored one of the very first productions out of New York. Brothers Joseph and Charles Douaihy are young, gay, and having a hell of a year. Their father has died and their uncle is losing it - putting the brothers' once unbreakable sense of humor to the test. As if that's not enough, Joseph is battling a mysterious ailment, and his eccentric boss is pressuring him to write a memoir about his Maronite Catholic family's tenuous connection to Kahlil Gibran, author of The Prophet. Things get even more intense when an ambitious and sexy reporter descends on the family in search of a story. Stephen Karam, author of the Stray Cat hits SPEECH AND DEBATE and columbinus pens a brutally funny comedy about family, culture and how where we come from plays a part in how we cope with wounds that just won't heal. *note: like most Stray Cat shows, this one contains adult language and situations The production will run Friday, February 15th 2013 through Sunday, March 2nd, 2012. All Thursday performances will have a 7 PM curtain. Fridays and Saturdays are at 8 PM, and Sundays are at 2 PM. Shows play OUr East Valley Alley at Tempe Performing Arts Center, 132 E 6th Street in Tempe's Mill Avenue District - close to ASU (at Forest Avenue, two blocks North of University). Tickets are $20 for Adults IN ADVANCE / $25 AT THE DOOR $18 for Seniors IN ADVANCE / $20 AT THE DOOR $15 for Students IN ADVANCE(w/Valid ID) / $18 AT THE DOOR. Thursdays are $10 Student Night. Sundays are $12 for EVERYBODY. Buy online at http://straycattheatre.org. Call 480.634.6435 with any questions. CAST: |


text:
hey beggars can't be choosers bud take your time!!!
hey beggars can't be choosers bud take your time!!!
BYE-BYE Little LION!!!
Is THAT what you call......."Lyin' DOWN"...??? :36_1_19[1 :36_11_6[1
By Eric Neel
Sweetness. The most stylish player in league history (only Lynn Swann comes close). Pick an image from your memory bank. I'll take the real-time slow-mo of his end-zone dives, a move I tried to imitate for hours as a kid, going up and over couch pillows piled high on the edge of the bed.
"Fly On, Proud Bird....Your Free At Last!!!"
To WALTER, with love..."Lynyrd Skynyrd"
http://images.allposters.com/images/PHO/AAFX026.jpg http://images.allposters.com/images/PHO/AAFX029.jpg
OK KEGGER I FOUND IT ALSO FOUND A TEAM PICTURE FROM 2001 AS SOON AS IM READY TO SEND IT I'LL PM YOU FOR YOUR ADDRESS OKQuote:
Originally Posted by kegstand
sounds awesome and I appreciate it thanks for finding that for me you ROCK!!!
Here's to the greatest NFL player that ever lived and an even better man.....he was an unbelievable person!!!!
It's 6.5MB so shouldn't take too long!
You may need Divx to be installed, if you can't play this. Find that here: http://download.divx.com/divx/DivXPlay.exe
awesome video. thanks keg. and thanks "Sweetness"! :respect: :bow:
That actually brought tears to my eyes! It´s almost unreal that we´ve had a runner like him...
I´ve thought a lot about Super Bowl XX and in a way it was just right that he didn´t get to score in that game. Because that was the player and man he was, unselfish and willing to give everything up for the team.
He was the GOAT!
I'm with ya motormouth that got me a little choked up and wishing we had a team like the super bowl one of 85!!
How much fun was he to watch play the game?
I´m just happy I got to see him play!Quote:
Originally Posted by kegstand
Team of ´85? Don´t get me started... The offensive line! Jimbo Covert, Jay Hilgenberg, Tom Thayer, Mark Bortz and Keith Van Horne! God Damn!
Kevin Butler, Gary Fencik, Willie Gault, I could go on forever...
Memories, memories...
Originally Posted by Motormouth
Indeed they're great to have would love to add some new ones but we'll always have the greatest NFL team EVER the 1985 Chicago Bears, what heart, charisma, personality.........they had it all!


text:
by Stéphane Aubier, Vincent Patar
Animated plastic toys like Cowboy, Indian and Horse have problems, too. Cowboy and Indian's plan to surprise Horse with a homemade birthday gift backfires when they destroy his house instead. Surreal adventures take over as the trio travel to the center of the earth, trek across frozen tundra and discover a parallel underwater universe where pointy-headed (and dishonest!) creatures live. Each speedy character is voiced -- and animated -- as if their very air contains both amphetamines and laughing gas. With panic a permanent feature of life in this papier mâché town, will Horse and his girlfriend ever be alone?
international title: | A Town Called Panic |
original title: | Panique au Village |
country: | Belgium, France |
sales agent: | Coproduction Office |
year: | 2009 |
genre: | animation |
directed by: | Stéphane Aubier, Vincent Patar |
release date: | BE 17/06/2009, HU 17/09/2009, FR 28/10/2009, NL 05/11/2009, NO 13/11/2009, IT 25/06/2010, ES 18/11/2011 |
production: | La Parti Production, Gebeka Films, Beast Animation, Made in Productions, Mélusine Productions, RTBF - Radio Télévision Belge de la Communauté Française, Les Films du Grognon (BE) |
backing: | Cnetre du Cinéma et de l'Audiovisuel de la Communauté française de la Belgique, Vlaams Audiovisueel fonds, Film Fund Luxemburg, Wallimage, Canal + |
distributor: | Cinéart, Gebeka Films, Nomad Film, Studio Canal, Szuez Film, Sherlock Films S.L. |


text:
UKVoucherCodes.com is a discount voucher codes website listing money saving codes and offers for you to use when shopping online at hundreds of the leading high street and favourite web based stores.
Featured Voucher Codes
We have carefully selected our top voucher codes for you to use, these free vouchers give the best savings for May 2013, shopping deals and great Father's Day gift ideas from some of the UK's most popular online retailers such as Tesco, Pizza Hut, Debenhams, Currys, Dell & Argos.
Sorry the voucher / offer your looking for had been deleted
Last Updated on Sunday May 26, 2013
Voucher Categories
- Baby and Toddler
- Books and Magazines
- Business
- CDs and DVDs
- Charities
- Clothing and Footwear
- Competitions
- Computers and Internet
- Daily Deals
- DIY and Tools
- Education
- Electronics and Appliances
- Experience Days
- Finance and Insurance
- Flights and Cruises
- Flowers
- Food and Drink
- Games and Consoles
- Gifts and Gadgets
- Health and Beauty
- Hobbies and Collectables
- Holidays Abroad
- Home and Garden
- Hotels and Accommodation
- Jewellery and Accessories
- Lingerie and Underwear
- Mobile Phones
- Motoring
- Music
- Pets
- Photo Printing
- Rent and Hire
- Services
- Shopping
- Sound and Vision
- Special Occasions
- Sports and Leisure
- Tickets
- Toys and Games
- Travel
- UK Holidays
Voucher Newsletter
Shop Search
Latest Codes
- BonmarcheFree deliveryExpires on: 30/05/2013Code:FREEPNPAFree UK Delivery on all items
- Dell Business10% OffExpires on: 02/06/2013Code:PRJ4D0KFZN8FMNGet 10% off all PowerEdge and PowerVault online orders when you spend over £1200
- Dell Business10% OffExpires on: 02/06/2013Code:W3RKHB$4GQ0BLW10% Off over £499 Performance Business Laptops, Tablets, Desktops, Workstations (Precision, Optiplex or Latitude)
- Dell Business15% OffExpires on: 02/06/2013Code:J0PR8W$68V8W1S15% Off over £699 Business Ultrabooks (Inspiron 15z, Inspiron 14z, XPS12, XPS13, XPS14, Latitude E6430u)
- ArgosUp to £100 of indoor furnitureExpires on: 28/05/2013Code:FURNSAVEIndoor furniture Save £20 when you spend £150 Save £50 when you spend £250 Save £100 when you spend £500 Offer available for online home delivery orders only.
- Brantano30% OffExpires on: 27/05/2013Code:DISCOUNT3030% Off Everything Online
- Universal Textiles15% OffExpires on: 02/06/2013Code:6EW9FTKF15% Off Half Term Special
- Davpack£10 OFFExpires on: 31/07/2013Code:APC5131-10£10 OFF orders over £129 (ex. VAT P&P)
UK Voucher Codes
UK Voucher Codes is free to use, simply copy the discount you want to use, click onto the retailers link and then shop as usual at your chosen shop and when its time to checkout paste the code into the relevant promotional box, you will then get a reduced total balance to pay thus saving you money!
To find a voucher for a specific retailer you can search by their name in the top search box or you can scroll on the "shops with vouchers" to find alphabetically which shops we currently have codes for.
Voucher Codes for UK Online Shopping
The idea of saving money is not a new concept. However, with the current economical times and the fact that even in the distant future individuals may still be feeling that financial pinch the idea of saving money in any moral way is more popular than it has been in decades. There are many ways to save money but one sought after and useful method is to shop online. Shopping online by itself often saves a great deal of money compared to typical brick and mortar stores that have to pay for extensive overhead and operating costs.
However, there is another method that can make even online shopping a much more economical experience. This method is the search and acquisition of discount voucher codes for use with online stores both small and international.
A voucher code can be used for practically anything and they come in a wide variety. Some allow direct savings of a certain amount such as a few pounds sterling. There are other voucher codes that allow for a specific percentage on any purchases to be saved.
What are the Voucher Code Styles?
The most common and popular types of voucher codes will come in the two forms previously mentioned. These vouchers will lower the price of a specific item or a group of the same items by a few pounds or by a set percentage.
There are other types of voucher codes however. There are buy one get one free type codes. There are codes where you buy a certain number and get a discount based on how many. This latter practice is called buying in bulk and it is a favourite tactic of discount online warehouses and any store that wants to be rid of excess merchandise.
How Much Can You Save?
The amount that can be saved varies with every voucher code. However, the savings are often quite extensive and most people that shop a lot can end up saving anywhere from one third to a half of what they would have spent overall. Some save far more than this, and others save much less. Either way, it is still far more economical than paying the straight retail price.
Where Do You Get Discount Voucher Codes?
There are many voucher codes to be found on our site, each month we list 100's of new codes to use with many top retailers, smart shoppers in the UK can often find anything they want at a discount online.


text:
In 2009 itek Energy's Founder, John Flanagan, inspired by the challenges presented by carbon intensive energy sources, chose to take his skill in manufacturing and apply it in the most tangible manner possible – build solar panels for Washington in Washington! After 4 years of research and investment the dream of itek Energy was born. In the first year of production, itek built over 7,000 panels, amounting to over a megawatt of solar built and installed in Washington itek has grown from a founding team of 3 to over 20 full time employees. With continual upgrades, we now have the production capacity to produce more than 60 megawatts of solar power per year, making us the largest solar manufacturer in Washington State.
From the start itek's focus has been to utilize quality and cost savings provided by bringing precision robotic assembly and proven lamination technology to local manufacturing. itek's designers and engineers are long time Washington locals and are passionate about solar. We build solar panels that are tailored for our Northwest weather. From the record setting snows of the North Cascades, to the strong and persistent winds of Central Washington, to the damp defuse light environments in the coastal regions, itek Energy panels are built to last and produce power regardless of where you live in Washington.


text:
Baker's Pride Inc., a commercial bakery and manufacturer of private label and proprietary baked products, named James Eagen director of bakery operations at the South Street Bakery, the newest Baker's Pride company. He will be responsible for bakery manufacturing at the South Street Bakery. He also has been appointed to the executive management committee at Baker's Pride.
Eagen has spent more than 22 years at Baker's Pride and its predecessor company, managing bakery operations. Before this appointment, he was manager of maintenance and sanitation at Mt. Pleasant Street Bakery. He earned a certification from the American Institute of Baking Sanitation program and studied at the University of Nebraska.


text:
I've mentioned before that bookshelves aren't my thing. Especially book shelves with kids books strewn all over the place. When I first saw these forward facing ones on Ohdeedoh back in January I got goosebumps.
Forward facing.
We have an IKEA about 25 minutes away and I had been a couple times looking for other things and would always end up in the kitchen gadget area looking for these spice racks. They were never there. Why does this always happen when you're so excited about something and then you go to get it and they don't have it?! The last trip I made I stumbled upon a whole pallet of them and just about shrieked out loud.
They are so perfect for kids books and for $3.99 each it sure beats the hassle of making them yourself!
They come with all the hardware to put them together - you just need screws to secure them into the wall.
I used my Rust-oleum "Almond" gloss left over from this table to spray paint them.
The natural wood color was pretty too but I tend to lean toward spray painting anything I can get my hands on. You choose.
Overcast + Rain + Huge bunk bed blocking any light coming in the window=awful picture taking day in an upstairs room...but you get my drift.
I used a stud finder to secure them into the wall. I realize that placing them so close to the bed is probably begging for a game of Tarzan, but I've threatened warned the boys that if they hang on them the monsters will come. And we haven't had monster sightings for months.