It's just casting. It's telling the compiler, "I know you only know about the value of this expression as type X, but I believe that at execution time it will be type Y. Check it for me at execution time, and then let me use it that way."
For example:
Object x = getValueFromSomewhere();
String text = (String) x; // I know x is a string reference really
// Use text as a normal string reference
If your belief in the type involved is incorrect (e.g. if the value of x
were a reference to an Integer
instead of a String
) then a ClassCastException
is thrown.
See the Java Inheritance Tutorial for more information (or just search for "Java casting tutorial" to find lots of similar ones) or see section 15.16 of the Java Language Specification for the details.