-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainLesson4_2.java
More file actions
41 lines (30 loc) · 1 KB
/
MainLesson4_2.java
File metadata and controls
41 lines (30 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package ru.MylearnCh1J1L1;
import java.util.LinkedList;
import java.util.Random;
public class MainLesson4_2 {
public static void main(String[] args) {
LinkedList<Integer> ll = new LinkedList<>();
randFillList(10, 100, ll);
System.out.println(ll);
enqueue(ll, 0);
System.out.println(ll);
System.out.println(dequeue(ll));
System.out.println(ll);
System.out.println(first(ll));
}
public static void enqueue(LinkedList<Integer> list, int value) {
list.add(value);
}
public static int dequeue(LinkedList<Integer> list) {
return list.removeFirst();
}
public static int first(LinkedList<Integer> list) {
return list.getFirst();
}
public static void randFillList(int count, int maxValue, LinkedList<Integer> list) {
Random rand = new Random();
for (int i = 0; i < count; i++) {
list.add(rand.nextInt(maxValue));
}
}
}