Code example for LinkedList

Methods: peek

0
 
        public MimeMessageBuilder() { 
        } 
 
        private void expect(Class<?> c) {
            if (!c.isInstance(stack.peek())) {
                throw new IllegalStateException("Internal stack error: " + "Expected '"
                                                + c.getName() + "' found '" + stack.peek().getClass().getName() + "'");
            } 
        } 
 
        public void startMessage() { 
            if (stack.isEmpty()) {
                stack.addFirst(MimeMessage.this);
            } else { 
                expect(Part.class); 
                try { 
                    MimeMessage m = new MimeMessage();
                    ((Part)stack.peek()).setBody(m);
                    stack.addFirst(m);
                } catch (MessagingException me) {