Skip to content

Instantly share code, notes, and snippets.

@Cristo86
Last active June 6, 2016 19:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Cristo86/7b68486f45dc5f4ed445e08157662007 to your computer and use it in GitHub Desktop.
Save Cristo86/7b68486f45dc5f4ed445e08157662007 to your computer and use it in GitHub Desktop.
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