Java Reference
In-Depth Information
The
return
keyword is optional when used as the last expression in a function
block. However, if you want to return immediately out of an
if
/
else
or loop,
you must use an explicit return.
In JavaFX, functions are objects in and of themselves and may be assigned to
variables. For example, to declare a function variable, assign a function to that
variable, and then invoke the function through the variable.
var glowFunction : function(level:Number):Glow;
glowFunction = glow;
glowFunction(1.0);
Functions definitions can also be anonymous. For example, for a function variable:
var glowFunction:
function(level:Number): Glow
=
function(level:Number) {
Glow { level: level };
};
Or, within an object literal declaration:
TextBox {
columns: 20
action:
function()
{
println("TextBox action");
}
}
Use
override
to override a function from a superclass.
class MyClass {
public function print() { println("MyClass"); }
}
class MySubClass extends MyClass {
override
function print() { println("MySubClass"); }
}
String literals can be specified using either double (
"
) or single (
'
) quotes. The
main reason to use one over the other is to avoid character escapes within the
string literal—for example, if the string literal actually contains double quotes.
Search WWH ::
Custom Search