mirror of
https://github.com/krahets/hello-algo.git
synced 2026-06-16 07:08:21 +08:00
Add ru version (#1865)
* Add Russian docs site baseline * Add Russian localized codebase * Polish Russian code wording * Update ru code translation. * Update code translation and chapter covers. * Fix pythontutor extraction. * Add README and landing page. * placeholder of profiles * Use figures of English version * Remove chapter paperbook
This commit is contained in:
40
ru/codes/java/chapter_stack_and_queue/queue.java
Normal file
40
ru/codes/java/chapter_stack_and_queue/queue.java
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* File: queue.java
|
||||
* Created Time: 2022-11-25
|
||||
* Author: krahets (krahets@163.com)
|
||||
*/
|
||||
|
||||
package chapter_stack_and_queue;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class queue {
|
||||
public static void main(String[] args) {
|
||||
/* Инициализация очереди */
|
||||
Queue<Integer> queue = new LinkedList<>();
|
||||
|
||||
/* Добавление элемента в очередь */
|
||||
queue.offer(1);
|
||||
queue.offer(3);
|
||||
queue.offer(2);
|
||||
queue.offer(5);
|
||||
queue.offer(4);
|
||||
System.out.println("Очередь queue = " + queue);
|
||||
|
||||
/* Доступ к элементу в начале очереди */
|
||||
int peek = queue.peek();
|
||||
System.out.println("Первый элемент peek = " + peek);
|
||||
|
||||
/* Извлечение элемента из очереди */
|
||||
int pop = queue.poll();
|
||||
System.out.println("Извлеченный элемент pop = " + pop + ", queue после извлечения = " + queue);
|
||||
|
||||
/* Получение длины очереди */
|
||||
int size = queue.size();
|
||||
System.out.println("Длина очереди size = " + size);
|
||||
|
||||
/* Проверка, пуста ли очередь */
|
||||
boolean isEmpty = queue.isEmpty();
|
||||
System.out.println("Пуста ли очередь = " + isEmpty);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user