Little Friends! Take a note today to share with everyone! This is the QQ Exchange Group I created: 315677448 interested in welcoming you to join. Not much nonsense to say directly into today's subject
ArrayList is the legendary dynamic array!
Let's create a test class with the following code:
package case0000014;import java.util.arraylist;public class test { public static void main (String[] args) { arraylist lis = new arraylist (); &NBSP;SYSTEM.OUT.PRINTLN ("add Mode"); lis.add ("A"); lis.add ("B"); lis.add ("C"); lis.add ("D"); Lis.add ("E"); //cycle out See for (Int i = 0; i < lis.size (); i++) { String result = (String) Lis.get (i); &nbsP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;SYSTEM.OUT.PRINTLN (Result); } system.out.println ("Delete method"); //Delete Method One: lis.remove ("a"); //Delete Mode two: Lis.remove (0); //cycle out See for (Int i = 0; i < lis.size (); i++) { String result = (String) Lis.get (i); system.out.println (result); } System.out.println ("modification Method"); &nBsp; lis.set (2, "F"); //loop out and see for (int i = 0; i < Lis.size (); i++) { string result = (String) lis.get (i); &NBSP;&NBSP;SYSTEM.OUT.PRINTLN (Result); } system.out.println ("Way to find"); // Gets the subscript String result = (String) of the dynamic array lis.get ( 0); system.out.println (result); }}
Copy My Code! Note the package name! This is just a simple usage, want to see more usage can join me outside of QQ inside discussion! You can also focus on my follow-up articles.
Dynamic array of Java: Simple application of ArrayList (add and revise)