⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 arraylist.html

📁 the teacher resource code about the secority
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>ArrayList Class</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body background="../figs/whitgran_y.jpg">
<p align="right"><font size="-1">&copy; Dmitry Gakhovich</font></p>
<p><strong><font color="#FF0000" size="+2">ArrayList Class</font></strong></p>
<p>ArrayList is very similar to a resizable array. Unlike arrays the an ArrayList 
  may contain <strong>only</strong> objects (not integers and other primitives).</p>
<p>ArrayList java class (<font color="#990000" size="-1" face="Courier New, Courier, mono">java.util.ArrayList</font>) 
  is very attarctive in many ways: </p>
<ul>
  <li> More convenient than ordinary arrays: you do not need to worry about null 
    references like in array elements</li>
  <li>You do not need to worry about a size of an ArrayList. Each time you add 
    an object to the ArrayList it's size grows by1, each time you delete an object 
    it shrinks by 1. Minimal size, of course, is 0.</li>
  <li>Easy to add and access elements.Some methods are:</li>
</ul>
<table width="95%" border="1" align="center">
  <tr> 
    <td colspan="2" bgcolor="#9999FF"><strong><font color="#000000" size="+1">Constructor and Method Summary</font></strong></td>
  </tr>
  <tr> 
    <td><font color="#FF0000">[constructor]</font></td>
    <td><strong><font color="#0000CC" face="Courier New, Courier, mono">ArrayList() </font></strong><br>
      Constructs an empty list with an initial capacity of ten.</td>
  </tr>
  <tr> 
    <td width="15%">boolean</td>
    <td width="85%"><strong><font color="#0000CC" face="Courier New, Courier, mono">add(Object 
      o) </font></strong><br>
      Appends the specified element to the end of this list.</td>
  </tr>
  <tr> 
    <td> Object</td>
    <td><strong><font color="#0000CC" face="Courier New, Courier, mono">get(int index) </font></strong><br>
      Returns the element at the specified position in this list.</td>
  </tr>
  <tr> 
    <td>Object</td>
    <td><font color="#0000CC" face="Courier New, Courier, mono"><strong>remove(int index) </strong></font><br>
      Removes the element at the specified position in this list.</td>
  </tr>
  <tr> 
    <td height="44">int</td>
    <td><strong><font color="#0000CC" face="Courier New, Courier, mono">size() </font></strong><br>
      Returns the number of elements in this list.</td>
  </tr>
</table>
<p><strong>Simple example:</strong></p>
<pre><font color="#990000" face="Courier New, Courier, mono">import java.util.ArrayList;</font></pre>
<pre><font color="#990000" face="Courier New, Courier, mono">public class AL{
   
   public static void main(String[] args) { 
   	ArrayList al = new ArrayList();
   	al.add(new String(&quot;one&quot;));
   	al.add(new String(&quot;two&quot;));
   	al.add(new String(&quot;three&quot;));
   	al.add(new String(&quot;four&quot;));
   	al.remove(0);
   	for(int i = 0;i&lt;al.size(); i++){
   		System.out.println(al.get(i)); 
   	} 
   }
}</font> 
</pre>
<font color="#FF0000"><strong>Output:</strong></font><br>
<table width="90%" border="1" bgcolor="black">
  <tr>
    <td><font color="#FFFFFF" size="-1" face="Courier New, Courier, mono"><strong>two<br>
      three<br>
      four</strong></font></td>
  </tr>
</table>
<p><strong>For more information see: <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/ArrayList.html" target="_blank">Java 
  API - ArrayList</a></strong></p>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -