Skip to content

Instantly share code, notes, and snippets.

@Cristo86
Last active June 6, 2016 19:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
void method() {
// traditional way
Foo.methodThatTakesArrays(new int[]{1,2,3,4,5,6,7,8});
// or..
Foo.methodThatTakesArrays(ai(1,2,3,4,5,6,7,8));
}
/**
* Array of ints
*/
private int[] ai(int...args) {
return args;
}
/**
* Array of objects
*/
private <E> E[] arr(E...args) {
return args;
}
// ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment