A typical example if you want to illustrate conciseness of functional code could use collections and their operations. E.g. consider a class Customer
and a method creating a sorted list of customer names from a list of customers.
Here is the Java implementation:
class Customer
{
String name;
... // Other attributes.
}
List<String> sortedCustomerNames(List<Customer> customers)
{
List<String> names = new ArrayList<String>();
for (Customer customer : customers)
names.add(customer.name);
Collections.sort(names);
return names;
}
Scala version:
class Customer(val name: String, /* ... other attributes */)
def sortedCustomerNames(customers: List[Customer]): List[String] =
customers.map(c => c.name).sorted
NOTE
Conciseness in terms of keystrokes is not always a good measure of code quality and maintainability.
Also, in general I would not advise to switch from Java to Scala just because Scala is newer. If most of the team members are more familiar with Java, the team will be much more productive with Java than with Scala (or any other programming language they don't know well).
I have been learning Scala in my free time for about two years now, and only recently (after attending an online course) I got the feeling I can be more productive in Scala than I am in Java. Before reaching this point, I would not have considered using Scala for production.