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

📄 crowd.java

📁 非常好的java事例以及带源码事例的java2教程
💻 JAVA
字号:
import java.util.*;

class Crowd
{
  // Constructors
  public Crowd()
  {
    // Create default Vector object to hold people
    people = new Vector();
  }

  public Crowd(int numPersons)
  {
    // Create Vector object to hold people with given capacity
    people = new Vector(numPersons);
  }

  // Add a person to the crowd
  public boolean add(Person someone)
  {
    return people.add(someone);     // Use the Vector method to add
  }

  // Get the person at a given index
  Person get(int index)
  {  return (Person)people.get(index);  }

  // Get number of persons in crowd
  public int size()
  { return people.size(); }

  // Get people store capacity
  public int capacity()
  { return people.capacity(); }

  // Get an iterator for the crowd
  public Iterator iterator()
  { return people.iterator(); }

  // Person store - only accessible through methods of this class
  private Vector people;    
}

⌨️ 快捷键说明

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