Java – I use generics, but not this class!
•
Java
I tried to use Google collections to call this method to connect two arrays
public static <T> T[] concat(T[] first,T[] second,Class<T> type)
It returns an empty result I'm using it
ObjectArrays.concat(array1,array2,Blah.class)
This is the only thing compiled
Array1 and array2 are of type blah []
What is correct grammar?
Additional question: do other collection libraries contain documents with examples?
Editor: the problem is my bone code
public void register(ButtonPair[] pairs) { pairs = ObjectArrays.concat(this.pairs,pairs,ButtonPair.class); }
The right side of things is good, but due to ambiguity, the left side is not assigned to this pairs. i 'm sorry! And hat Google collection!
Solution
The following are useful to me:
String[] arr1 = { "abc","def" }; String[] arr2 = { "ghi","jkl" }; String[] result = ObjectArrays.concat(arr1,arr2,String.class);
How do you get results from concat()?
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码