Skip to content

Commit 537fc20

Browse files
committed
ArrayUtils: add method for easily creating arrays
I don't know if heap pollution is a potential problem here. But the method sure is mighty convenient... so here we go.
1 parent 24790f3 commit 537fc20

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/main/java/org/scijava/util/ArrayUtils.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ private ArrayUtils() {
7979

8080
// -- ArrayUtils methods --
8181

82+
/** Creates an array of the given type, containing the specified values. */
83+
@SafeVarargs
84+
public static <T> T[] array(final T... values) {
85+
return values;
86+
}
87+
8288
/**
8389
* Converts the provided Object to a {@link Collection} implementation. If the
8490
* object is an array type, a {@link PrimitiveArray} wrapper will be created.

0 commit comments

Comments
 (0)