11. Calling Java

use java "..." calls a Java class directly. Every Java call counts as !io, and a reference return type is wrapped in Option[T] automatically — null does not get into Dawn. Construct with .new, and call static methods on the class name.

use java "java.lang.Math"

pub fn main() -> Unit !io = {
  let n = Math.abs(-7)
  println(to_string(n))
}
Open in playground
7