boolean nameHasUpperCase = false; // This is Java
for (int i = 0; i < name.length(); ++i) {
if (Character.isUpperCase(name.charAt(i))) {
nameHasUpperCase = true;
break;
}
}
in Java to
boolean nameHasUpperCase = !name.toLowerCase().equals(name);
in Java to
val nameHasUpperCase = name.exists(_.isUpperCase)
in Scala.
From the article "How Scala Changed My Programming Style" by Bill Venners.