Use the knowledge you have learned in data structures and algorithms to write a class Stack and write an application to test the stack (call its public method ). (-- Instructor Wang, computer 082java, from Ningbo University, has all rights reserved. Baidu hasn't found it)
To achieve the stack, you can use the Linked List (defined by the Java System) (using import Java. util. * Reference). You can also use arrays or even define a class yourself, just like the linked list in C ++, and define the element class.
For example ......
Import Java. util. *; <br/> public class mystack {<br/> Public static void main (string [] ARGs) <br/>{< br/> reverse list <string> zrq = New reverse list <string> (); <br/> // insert <br/> for (INT I = 0; I <= 4; I ++) <br/>{< br/> zrq. addlast (integer. tostring (I); <br/>}< br/> while (! Zrq. isempty () <br/>{< br/> system. out. println (LLS. removefirst (); <br/>}< br/>
This is the inbound stack. Let's figure out what Stack is. ^_^