Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这不是非常重要,但我很好奇是否有一种方法可以编写一个 Java 单衬里,可能使用番石榴或其他东西来填充具有相同值的元素的数组。所以例如像Arrays.getSameElementArray(new long[12], 42L);
Arrays.getSameElementArray(new long[12], 42L);
是的,
long[] arr = new long[12]; Arrays.fill(arr, 42L);
你可以这样做:
long[] values = new long[12]; Arrays.fill(values, 42l);