JavaCast
Cast a variable to a specified Java type
Method Signature
JavaCast(type=[string], variable=[any])
Arguments
Argument
Type
Required
Description
Default
type
string
true
The name of a Java primitive or a Java class name.
variable
any
true
The variable, Java object, or array to cast.
Examples
Convert a Boxlang Number to a Java double primitive
Converts the number 180.0 degrees to radians using Java method: Math.toRadians(double degrees)
createObject( "java", "java.lang.Math" ).toRadians( javaCast( "double", 180.0 ) );
Result: 3.141592653589793
Additional Examples
// Convert a Boxlang Number to a Java double primitive
// Converts the number 180.0 degrees to radians using Java method: Math.toRadians(double degrees)
writeDump( createObject( "java", "java.lang.Math" ).toRadians( javacast( "double", 180.0 ) ) );
Related
Last updated
Was this helpful?