Converted more Scala code to Java