Code snippet 3

Posted January 15th, 2011 in Snippets and tagged , , by Metod

At the moment I am doing some java programming. And since being primarily a php guy, I was wondering how to easily return an array from a method like you can in php:

public function returnArray() {
    return array(1, 2, 3);

And I found a way which is quite nice:

public int[] returnArray() {
    return new int[]{1, 2, 3};