move array math to java