2000Fall

Awt import javaawtevent import javaxswing class

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: urs; } }    3%  (%   ;(+,5%,catch (Exception e)" /% #$5 $ ?)$%++5)$ 0 +&("/ ,%$$ 0?)%&+"   #$ 5&&0,  %,%      % 5 ) $&," - $  &"   Stack s = new Stack(); try { s.pop(); } catch {EmptyStackException e) { } Ans: Stack s = new Stack(); if (!s.empty()) s.pop();  E (b) istream is; Stack s; for (i=0; i<100; i++){ try { n = s.pop(); } catch (EmptyStackException s) { // stack was empty } try { out.writeInt(n); } catch (IOException e) { // problem writing to a file } }  Solution: try { for (i=0; i<100; i++) { n = s.pop(); out.writeInt(n); } } catch (IOException e) { ... } catch (EmptyStackException s) { ... }     #$5&...
View Full Document

Ask a homework question - tutors are online