範例：以陣列實作 List

class List
{
public static void main(String[] args)
{
int a[] = new int[6];
int size = 0;
size = append(a, size, 3);
print(a, size);
size = append(a, size, 5);
print(a, size);
size = append(a, size, 2);
print(a, size);
size = append(a, size, 4);
print(a, size);
size = append(a, size, 1);
print(a, size);
size = delete(a, size, 2);
print(a, size);
size = delete(a, size, 4);
print(a, size);
int i = find(a, size, 5);
System.out.println("i="+i);
int j = find(a, size, 2);
System.out.println("j="+j);
}

public static void print(int a[], int size)
{
for (int i=0; i<size; i++)
System.out.print(a[i]+" ");
System.out.println();
}

public static int find(int a[], int size, int x)
{
for (int i=0; i<size; i++)
if (a[i] == x) return i;
return -1;
}

public static int append(int a[], int size, int x)
{
a[size] = x;
return size+1;
}

public static int delete(int a[], int size, int x)
{
int k = find(a, size, x);
if (k >= 0)
{
for (int i=k; i<size; i++)
a[i] = a[i+1];
return size-1;
}
else
return size;
}
}