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)
Asked
Active
Viewed 29 times
0
Chris Gong
- 8,031
- 4
- 30
- 51
Utsav Kumar
- 13
- 1
- 3
-
5Can you show the problematic and successful code? – The Head Rush Mar 17 '17 at 20:05
-
1Please add the source code, so we can help you. – reos Mar 17 '17 at 20:34
-
2Can't imagine what you are saying. Please post a snippet. – robot_alien Mar 17 '17 at 20:34
1 Answers
-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
TinkerTenorSoftwareGuy
- 798
- 7
- 15