0

First, i initialized my ArrayList to null, then I tried to initialize it with a String, but it doesn't overwrite the String. Now I initialize my ArrayList with another ArrayList containing a String and it works, can someone explain it? (implementation is done in java)

Chris Gong
  • 8,031
  • 4
  • 30
  • 51
Utsav Kumar
  • 13
  • 1
  • 3

1 Answers1

-1
// This creates a new ArrayList paramaterized to store Strings
ArrayList<String> list = new ArrayList<String>();

You can call various methods on list, now, such as add or remove, and you get do this at a specific index, just like you would with an array. The difference is the ArrayList can grow or shrink in size.

For some examples:

https://www.tutorialspoint.com/java/java_arraylist_class.htm