Dynamic array of Java: Simple application of ArrayList (add and revise)

Source: Internet
Author: User

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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.