Generics

Generics are a great way to prevent bugs at runtime since they provide compile-time type checking and promote cast elimination. Another important advantage of using generics is that you can write code that uses abstractions instead of concrete classes, so you can create maintainable and extendable code. The following example shows how we can print a collection containing different types using generics: import java.util.List; import java.util.Arrays; public class ListPrinter { private <T> void printList(List<T> collection){ for(T item: collection){ System. [Read More]

Java

There are three main features in Java 8 that I love, one of them is the lambda expressions, it will have enormous implications for simplifying development. The another one is the new java.util.stream package provide a Stream API to support functional-style operations on streams of elements. The Stream API is integrated into the Collections API, which enables bulk operations on collections, such as sequential or parallel map-reduce transformations. And lastly but not least the java. [Read More]