回答編集履歴
4
内容修正
test
CHANGED
@@ -116,6 +116,16 @@
|
|
116
116
|
|
117
117
|
|
118
118
|
|
119
|
+
* [java.util.stream.Stream](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/Stream.html)
|
120
|
+
|
121
|
+
* [#flatMap()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/Stream.html#flatMap-java.util.function.Function-)
|
122
|
+
|
123
|
+
* [#map()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/Stream.html#map-java.util.function.Function-)
|
124
|
+
|
125
|
+
* [#collect()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/stream/Stream.html#collect-java.util.stream.Collector-)
|
126
|
+
|
127
|
+
|
128
|
+
|
119
129
|
```java
|
120
130
|
|
121
131
|
final List<Point2D> points = new ArrayList<>();
|
3
内容修正
test
CHANGED
@@ -101,3 +101,43 @@
|
|
101
101
|
}
|
102
102
|
|
103
103
|
```
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
----
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
> KosukeDayo_
|
112
|
+
|
113
|
+
> 2020/04/21 23:45
|
114
|
+
|
115
|
+
> final List<Point2D> points = から Collections.shuffle(points, new SecureRandom()); までで行っている動作の説明をしていただいてもよろしいでしょうか・・・?初学者のため、申し訳ありません。
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
```java
|
120
|
+
|
121
|
+
final List<Point2D> points = new ArrayList<>();
|
122
|
+
|
123
|
+
for (int x : listX) {
|
124
|
+
|
125
|
+
for (int y : listY) {
|
126
|
+
|
127
|
+
points.add(new Point2D(x, y));
|
128
|
+
|
129
|
+
}
|
130
|
+
|
131
|
+
}
|
132
|
+
|
133
|
+
|
134
|
+
|
135
|
+
// final List<Point2D> points =
|
136
|
+
|
137
|
+
// listX.stream().flatMap(x ->
|
138
|
+
|
139
|
+
// listY.stream().map(y -> new Point2D(x, y))
|
140
|
+
|
141
|
+
// ).collect(Collectors.toList());
|
142
|
+
|
143
|
+
```
|
2
内容修正
test
CHANGED
@@ -41,3 +41,63 @@
|
|
41
41
|
// [o, e, d, p, m, b, k, g, l, j, c, f, n, i, a, h]
|
42
42
|
|
43
43
|
```
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
----
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
質問の意図を読み違えていました。追記します。
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
上記を使い、こんな感じではどうでしょうか。
|
56
|
+
|
57
|
+
|
58
|
+
|
59
|
+
```java
|
60
|
+
|
61
|
+
import javafx.geometry.Point2D;
|
62
|
+
|
63
|
+
...
|
64
|
+
|
65
|
+
@Test
|
66
|
+
|
67
|
+
public void ccc() {
|
68
|
+
|
69
|
+
final Button[] buttons = new Button[]{...};
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
final List<Integer> listX = Arrays.asList(20, 80, 140, 200);
|
74
|
+
|
75
|
+
final List<Integer> listY = Arrays.asList(270, 330, 390, 450);
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
final List<Point2D> points =
|
80
|
+
|
81
|
+
listX.stream().flatMap(x ->
|
82
|
+
|
83
|
+
listY.stream().map(y -> new Point2D(x, y))
|
84
|
+
|
85
|
+
).collect(Collectors.toList());
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
Collections.shuffle(points, new SecureRandom());
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
for (int index = 0; index < buttons.length; index++) {
|
94
|
+
|
95
|
+
buttons[index].setLayoutX(points.get(index).getX());
|
96
|
+
|
97
|
+
buttons[index].setLayoutY(points.get(index).getY());
|
98
|
+
|
99
|
+
}
|
100
|
+
|
101
|
+
}
|
102
|
+
|
103
|
+
```
|
1
typo
test
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
シャッフル機能。やりたいことそのもののメソッドがあります。[Collections#shuffle()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#shuffle-java.util.List-java.util.Random-)
|
1
|
+
シャッフル機能。やりたいことそのもの名前のメソッドがあります。[Collections#shuffle()](https://docs.oracle.com/javase/jp/8/docs/api/java/util/Collections.html#shuffle-java.util.List-java.util.Random-)
|
2
2
|
|
3
3
|
|
4
4
|
|