public class Table {
/* // 初始化的最大存储容量
public static final int Size = 5;
// 存储数据
public int[] head;
// 顺序表的长度
public int length;
// 顺序表的存储容量
public int size;
*//**
* 初始化顺序表
* @param t
*//*
public static void initTable(Table t){
// 给顺序表发配动态的存储空间
t.head = new int[Size];
// 判断顺序表是否申请失败
if(t.head == null){
System.out.println("顺序表申请失败");
System.exit(0);
}
// 初始化顺序表的长度
t.length = 0;
// 初始化申请表的内存空间大小
t.size = Size;
}
// 打印顺序表
public static void displayTable(Table t){
for(int i = 0; i < t.length; i ++){
System.out.println(t.head[i] + " ");
}
}
public static void main(String[] args) {
Table t = new Table();
initTable(t);
for(int i = 0; i < Size; i ++){
t.head[i] = i + 1;
t.length ++;
}
displayTable(t);
}*/
public static final int Size = 5;
public int[] head;
public int length;
public int size;
public static void initTable(Table t){
t.head = new int[Size];
if(t.head == null){
System.exit(0);
}
t.length = 0;
t.size = Size;
}
public static void display(Table t){
for(int i = 0; i < t.length; i ++){
System.out.println(t.head[i]);
}
}
public static void main(String[] args) {
Table t = new Table();
initTable(t);
for(int i = 0; i < Size; i ++){
t.head[i] = i + 1;
t.length ++;
}
display(t);
}
}