Yield Return in Java

Posted by & filed under c#, Java.

A feature often missed in Java by c# developers is yield return It can be used to create Iterators/Generators easily. For example, we can print the infinite series of positive numbers like so: public static void Main() { foreach (int i in positiveIntegers()) { Console.WriteLine(i); } }   public static IEnumerable<int> positiveIntegers() { int i… Read more »

MultiCatch in c# and old java

Posted by & filed under c#, Java.

Someone on IRC was asking whether it was possible to do catch multiple types of exceptions at the same time in c#. In Java 7 there’s a feature from project coin called multi catch that enables the following syntax: public class MultiCatch { public static void main(String… args) { try { throw new ExceptionA(); }… Read more »