zoukankan      html  css  js  c++  java
  • 数组列表

    An ArrayList provides an alternative way of storing a list of objects and has the following advantages over an array:
    • An ArrayList shrinks and grows as needed in a program ,whereas an array has fixed length that is set when the array is created.
    • In an ArrayLIst list, the last slot is always list.size()-1, whereas in a partially filled array, you ,the programmer,must keep track of the last slot currently in use.
    • For an ArrayList ,you can do insertion or deletion with just a single statement.Any shifting of elements is handled automatically . In an array ,however ,insertion or deletion requires you to write the code than shifts the elements.
    • It is easier to print the elements of an ArrayList than those of an array.For an ArrayLIst list and an array arr ,the statement

            System.out.print(list) ;

       will output the elements of list, nicely formatted in square brackets, with the elements separated by commas. Whereas to print the elements of arr, an explicit plece of code that accesses and prints each element is needed, the statement 

            System.out.print(arr); 

        will produce weird output that includes an @ symbol and the hashcode of arr in hexadecimal.

     

  • 相关阅读:
    linux常用命令使用指南
    小赢理财招聘 测试开发、专项
    小赢理财招聘 测试开发、专项
    【模板】普通平衡树
    about乘法逆元
    luogu P2234 [HNOI2002]营业额统计
    线性筛中求莫比乌斯函数‘
    欧拉函数
    围棋
    丛林中的路
  • 原文地址:https://www.cnblogs.com/hzhuxin/p/15602522.html
Copyright © 2011-2022 走看看