数组和集合

uses System.Generics.Collections;

var
  IntStack: TStack<Integer>;
  Top, First, Second, Third: Integer;
begin
  IntStack := TStack<Integer>.Create;
  IntStack.Push(1);
  IntStack.Push(3);
  IntStack.Push(5);

  Top := IntStack.Peek;
  //top is 5
  First := IntStack.Pop;
  //first is 5
  Second := IntStack.Pop;
  //second is 3
  Third := IntStack.Pop;
  //third is 1

  WriteLn('top is ', Top);
  WriteLn('first is ', First);
  WriteLn('second is ', Second);
  WriteLn('third is ', Third);
end.