java中list的使用方法

来源:百度知道 编辑:UC知道 时间:2024/05/19 17:41:34

LIST是个容器接口,可以理解为动态数组,传统数组必须定义好数组的个数才可以使用,而容器对象无须定义好数组下标总数,用add()方法即可添加新的成员对象,他可以添加的仅仅只能为对象,不能添加基本数据类型,容器还对应get(),remove()方法来获取和删除数据成员

import java.io.*;
import java.awt.*; // AWT classes for the demo program
import javax.swing.*; // Swing GUI classes for the demo

/**
* This class contains a useful static method for listing all threads
* and threadgroups in the VM. It also has a simple main() method so it
* can be run as a standalone program.
**/
public class ThreadLister {
/** Display information about a thread. */
private static void printThreadInfo(PrintWriter out, Thread t,
String indent) {
if (t == null) return;
out.println(indent + "Thread: " + t.getName() +
" Priority: " + t.getPriority() +
(t.isDaemon()?" Daemon":"") +
(t.isAlive()?"":" Not Alive"));
}