githubEdit

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)

Run Examplearrow-up-right

createObject( "java", "java.lang.Math" ).toRadians( javaCast( "double", 180.0 ) );

Result: 3.141592653589793

Additional Examples

Run Examplearrow-up-right

Last updated

Was this helpful?