Array of string lists

  • 6
  • Locked
Sometimes a task is just a task. With no dirty tricks, and no need to look for complexity or depth. You just need to sit down and do it. Just such a task is before us. See how everything is clear and simple: create an array whose elements are lists of strings. And then fill the array with any data and display it on the screen.
You can't complete this task, because you're not signed in.
Comments (3)
  • Popular
  • New
  • Old
You must be signed in to leave a comment
Max Sudik
Level 30 , Vancouver, Canada
30 September 2021, 21:50
In the provided solution the ArrayList was declared like this:
ArrayList<String>[] result = (ArrayList<String>[]) new ArrayList[3];
In my case I declared as this and everything worked:
ArrayList<String>[] result = new ArrayList[3];
Could you explain me why do we need or don't need to cast here? Thanks, M
Jomar Tayactac
Level 18 , Winnipeg, Canada
6 December 2021, 23:14
Curious about this as well. Did you find your answer?
Level 15 , Bogota, Colombia
10 November 2020, 20:27
it took me a good couple of hours exploring different versions of the code to get to a point where I was comfortable verifying. I still don't feel like I get the full picture of these kinds of algorithms. But if I had a tip for any one struggling with this task, it would be to be careful with how and when you initialize the arrays and the lists. Also play around with how data flows inside nested for loops