Institute of Computer Science
  1. Courses
  2. 2017/18 spring
  3. Object-Oriented Programming (Narva College) (P2NC.01.083)
ET
Log in

Object-Oriented Programming (Narva College) 2017/18 spring

  • Home
  • Materials
  • Java Glossary
  • Source Example
  • Cheat sheet (S1-S6)
  • Grading
  • Links
Session 12

Deque

A stack is a conceptual structure consisting of a set of homogeneous elements and is based on the principle of the last inserted elements are retrieved first; therefore, this data structure is also known as LIFO (last-in-first-out). It is a commonly used abstract data type with two major operations, namely push and pop. The elements are appended to the end of the deque (push) and are removed (pop) from the end of the stack. In Java, stacks can be presented by the Deque interface. The Deque interface extends the Queue interface. The name deque is short for double ended queue.

// s of the Deque (double-ended queue) interface has functionality of the stack
Deque<Integer> s = new ArrayDeque<>(); 
s.push(1); 
s.push(2); 
s.push(3); 
System.out.print(s.pop()); // 3
System.out.print(s.pop()); // 2
System.out.print(s.pop()); // 1
Session 12
  • Institute of Computer Science
  • Faculty of Science and Technology
  • University of Tartu
In case of technical problems or questions write to:

Contact the course organizers with the organizational and course content questions.
The proprietary copyrights of educational materials belong to the University of Tartu. The use of educational materials is permitted for the purposes and under the conditions provided for in the copyright law for the free use of a work. When using educational materials, the user is obligated to give credit to the author of the educational materials.
The use of educational materials for other purposes is allowed only with the prior written consent of the University of Tartu.
Terms of use for the Courses environment