CodeX
Published in

CodeX

The future of Java is to absorb Scala features

Photo by Lindsay Henwood on Unsplash
var transactions: List[Transaction] = List()
List<Transaction> transactions = new ArrayList<>();
SomeReallyLongClassName obj = new SomeReallyLongClassName(param);
var obj = new SomeReallyLongClassName(param);
scala> res13.filter(isPrime)
res14: IndexedSeq[Int] = Vector(3, 7, 13, 31, 43, 73, 157, 211, 241, 307, 421, 463, 601, 757, 1123, 1483, 1723, 2551, 2971, 3307, 3541, 3907, 4423, 4831, 5113, 5701, 6007, 6163, 6481, 8011, 8191, 9901)
res13.stream().filter(new Predicate<Integer> {    @Override
public boolean test(Integer v) {
return isPrime(v);
}
});
val minBalAccounts = accounts.filter(_.balance < MINIMUM_BALANCE)
def isPrime(num: Int): Boolean = Math.abs(num) match {
case 0 => false
case 1 => false
case n => (2 to
Math.floor(Math.sqrt(n)).toInt) forall (p => n % p != 0)
}
urlConn match {
case httpsConn: HttpsURLConnection => // TODO: Process HTTPS
case httpConn: HttpURLConnection => // TODO: Process HTTP
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alonso Del Arte

is a Java and Scala developer from Detroit, Michigan. AWS Cloud Practitioner Foundational certified