+/EE360P
distributed systems
git clone https://git.julia.blue/+/EE360P
cccc41d
master
1import java .util .NoSuchElementException ; 2 3public class Stack <T > { 4Node <T >top =null ; 5 6public synchronized void push (T value ) { 7Node <T >node =new Node (value ); 8node .next =top ; 9top =node ; 10 } 11 12public synchronized T pop ()throws NoSuchElementException { 13if (top ==null ) { 14throw new NoSuchElementException (); 15 }else { 16Node <T >oldTop =top ; 17top =top .next ; 18return oldTop .value ; 19 } 20 21 } 22 23}