Can you rewrite it in java?