Arrays inside an array with generic class? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Arrays inside an array with generic class?

Say I have a class called StoreArray which has a generic parameter. When a object of it is created, it initializes an array called storage with parameter int length. So if I made: StoreArray<String> s = new StoreArray<String>(5) It would create the storage array 5 spaces. But If I want to create a object that stores arrays , how do I go about doing that. I thought: StoreArray<String[]> s = new StoreArray<String[]>(5) That would make 5 arrays Inside storage I think. But how do I set the Length of each array?

15th Sep 2019, 2:39 PM
Jamie Charles
1 Answer
0
If i wanted to set the length to 4 of each array, could i put <String[4]> instead?
15th Sep 2019, 2:44 PM
Jamie Charles