- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在 java 中有一个字符串数组的 ArrayList,名为:
List<String[]> initialList = new ArrayList<String[]>();
它包含以下数据(这是它的一个片段,它实际上包含大约 900 行,其中还包括 Charlie、Delta、Echo,每行都与这些数据具有相同的结构:
[Alpha, A1, 1, null]
[Alpha, A1, 2, null]
[Alpha, A1, 3, null]
[Alpha, A1, 4, null]
[Alpha, A1, 5, null]
[Alpha, A1, 6, null]
[Alpha, A1, 7, null]
[Alpha, A1, 8, null]
[Alpha, A1, 9, null]
[Alpha, A1, 10, null]
[Alpha, A1, 11, null]
[Alpha, A1, 12, null]
[Alpha, A1, 13, null]
[Alpha, A1, 14, null]
[Alpha, A1, 15, null]
[Alpha, A1, 16, null]
[Alpha, A1, 17, null]
[Alpha, A1, 18, null]
[Alpha, A1, 19, null]
[Alpha, A1, 20, null]
[Alpha, A1, 21, null]
[Alpha, A1, 22, null]
[Alpha, A1, 23, null]
[Alpha, A1, 24, null]
[Alpha, A1, 25, null]
[Alpha, A1, 26, null]
[Alpha, A1, 27, null]
[Alpha, A1, 28, null]
[Alpha, A1, 29, null]
[Alpha, A1, 30, null]
[Alpha, A1, 31, null]
[Alpha, A1, 32, null]
[Alpha, A1, 33, null]
[Alpha, A1, 34, null]
[Alpha, A1, 35, null]
[Alpha, A1, 36, null]
[Alpha, A1, 37, null]
[Alpha, A1, 38, null]
[Alpha, A1, 39, null]
[Alpha, A1, 40, null]
[Alpha, A1, 41, null]
[Alpha, A1, 42, null]
[Alpha, A1, 43, null]
[Alpha, A1, 44, null]
[Alpha, A1, 45, null]
[Alpha, A1, 46, null]
[Alpha, A1, 47, null]
[Alpha, A1, 48, null]
[Alpha, A1, 49, null]
[Alpha, A1, 50, null]
[Alpha, A1, 51, null]
[Alpha, A1, 52, null]
[Alpha, A1, 53, null]
[Alpha, A1, 54, null]
[Alpha, A2, 1, null]
[Alpha, A2, 2, null]
[Alpha, A2, 3, null]
[Alpha, A2, 4, null]
[Alpha, A2, 5, null]
[Alpha, A2, 6, null]
[Alpha, A2, 7, null]
[Alpha, A2, 8, null]
[Alpha, A2, 9, null]
[Alpha, A2, 10, null]
[Alpha, A2, 11, null]
[Alpha, A2, 12, null]
[Alpha, A2, 13, null]
[Alpha, A2, 14, null]
[Alpha, A2, 15, null]
[Alpha, A2, 16, null]
[Alpha, A2, 17, null]
[Alpha, A2, 18, null]
[Alpha, A2, 19, null]
[Alpha, A2, 20, null]
[Alpha, A2, 21, null]
[Alpha, A2, 22, null]
[Alpha, A2, 23, null]
[Alpha, A2, 24, null]
[Alpha, A2, 25, null]
[Alpha, A2, 26, null]
[Alpha, A2, 27, null]
[Alpha, A2, 28, null]
[Alpha, A2, 29, null]
[Alpha, A2, 30, null]
[Alpha, A2, 31, null]
[Alpha, A2, 32, null]
[Alpha, A2, 33, null]
[Alpha, A2, 34, null]
[Alpha, A2, 35, null]
[Alpha, A2, 36, null]
[Alpha, A2, 37, null]
[Alpha, A2, 38, null]
[Alpha, A2, 39, null]
[Alpha, A2, 40, null]
[Alpha, A2, 41, null]
[Alpha, A2, 42, null]
[Alpha, A2, 43, null]
[Alpha, A2, 44, null]
[Alpha, A2, 45, null]
[Alpha, A2, 46, null]
[Alpha, A2, 47, null]
[Alpha, A2, 48, null]
[Alpha, A2, 49, null]
[Alpha, A2, 50, null]
[Alpha, A2, 51, null]
[Alpha, A2, 52, null]
[Alpha, A2, 53, null]
[Alpha, A2, 54, null]
[Alpha, A3, 1, null]
[Alpha, A3, 2, null]
[Alpha, A3, 3, null]
[Alpha, A3, 4, null]
[Alpha, A3, 5, null]
[Alpha, A3, 6, null]
[Alpha, A3, 7, null]
[Alpha, A3, 8, null]
[Alpha, A3, 9, null]
[Alpha, A3, 10, null]
[Alpha, A3, 11, null]
[Alpha, A3, 12, null]
[Alpha, A3, 13, null]
[Alpha, A3, 14, null]
[Alpha, A3, 15, null]
[Alpha, A3, 16, null]
[Alpha, A3, 17, null]
[Alpha, A3, 18, null]
[Alpha, A3, 19, null]
[Alpha, A3, 20, null]
[Alpha, A3, 21, null]
[Alpha, A3, 22, null]
[Alpha, A3, 23, null]
[Alpha, A3, 24, null]
[Alpha, A3, 25, null]
[Alpha, A3, 26, null]
[Alpha, A3, 27, null]
[Alpha, A3, 28, null]
[Alpha, A3, 29, null]
[Alpha, A3, 30, null]
[Alpha, A3, 31, null]
[Alpha, A3, 32, null]
[Alpha, A3, 33, null]
[Alpha, A3, 34, null]
[Alpha, A3, 35, null]
[Alpha, A3, 36, null]
[Alpha, A3, 37, null]
[Alpha, A3, 38, null]
[Alpha, A3, 39, null]
[Alpha, A3, 40, null]
[Alpha, A3, 41, null]
[Alpha, A3, 42, null]
[Alpha, A3, 43, null]
[Alpha, A3, 44, null]
[Alpha, A3, 45, null]
[Alpha, A3, 46, null]
[Alpha, A3, 47, null]
[Alpha, A3, 48, null]
[Alpha, A3, 49, null]
[Alpha, A3, 50, null]
[Alpha, A3, 51, null]
[Alpha, A3, 52, null]
[Alpha, A3, 53, null]
[Alpha, A3, 54, null]
[Alpha, A3, 55, null]
[Alpha, A3, 56, null]
[Alpha, A3, 57, null]
[Alpha, A3, 58, null]
[Alpha, A3, 59, null]
[Alpha, A3, 60, null]
[Alpha, A4, 1, null]
[Alpha, A4, 2, null]
[Alpha, A4, 3, null]
[Alpha, A4, 4, null]
[Alpha, A4, 5, null]
[Alpha, A4, 6, null]
[Alpha, A4, 7, null]
[Alpha, A4, 8, null]
[Alpha, A4, 9, null]
[Alpha, A4, 10, null]
[Alpha, A4, 11, null]
[Alpha, A4, 12, null]
[Alpha, A4, 13, null]
[Alpha, A4, 14, null]
[Alpha, A4, 15, null]
[Alpha, A4, 16, null]
[Alpha, A4, 17, null]
[Alpha, A4, 18, null]
[Alpha, A4, 19, null]
[Alpha, A4, 20, null]
[Alpha, A4, 21, null]
[Alpha, A4, 22, null]
[Alpha, A4, 23, null]
[Alpha, A4, 24, null]
[Alpha, A4, 25, null]
[Alpha, A4, 26, null]
[Alpha, A4, 27, null]
[Alpha, A4, 28, null]
[Alpha, A4, 29, null]
[Alpha, A4, 30, null]
[Alpha, A4, 31, null]
[Alpha, A4, 32, null]
[Alpha, A4, 33, null]
[Alpha, A4, 34, null]
[Alpha, A4, 35, null]
[Alpha, A4, 36, null]
[Alpha, A4, 37, null]
[Alpha, A4, 38, null]
[Alpha, A4, 39, null]
[Alpha, A4, 40, null]
[Alpha, A4, 41, null]
[Alpha, A4, 42, null]
[Alpha, A4, 43, null]
[Alpha, A4, 44, null]
[Alpha, A4, 45, null]
[Alpha, A4, 46, null]
[Alpha, A4, 47, null]
[Alpha, A4, 48, null]
[Alpha, A4, 49, null]
[Alpha, A4, 50, null]
[Alpha, A4, 51, null]
[Alpha, A4, 52, null]
[Alpha, A4, 53, null]
[Alpha, A4, 54, null]
[Alpha, A4, 55, null]
[Alpha, A4, 56, null]
[Alpha, A4, 57, null]
[Alpha, A4, 58, null]
[Alpha, A4, 59, null]
[Alpha, A4, 60, null]
[Bravo, B1, 1, null]
[Bravo, B1, 2, null]
[Bravo, B1, 3, null]
[Bravo, B1, 4, null]
[Bravo, B1, 5, null]
[Bravo, B1, 6, null]
[Bravo, B1, 7, null]
[Bravo, B1, 8, null]
[Bravo, B1, 9, null]
[Bravo, B1, 10, null]
[Bravo, B1, 11, null]
[Bravo, B1, 12, null]
[Bravo, B1, 13, null]
[Bravo, B1, 14, null]
[Bravo, B1, 15, null]
[Bravo, B1, 16, null]
[Bravo, B1, 17, null]
[Bravo, B1, 18, null]
[Bravo, B1, 19, null]
[Bravo, B1, 20, null]
[Bravo, B1, 21, null]
[Bravo, B1, 22, null]
[Bravo, B1, 23, null]
[Bravo, B1, 24, null]
[Bravo, B1, 25, null]
[Bravo, B1, 26, null]
[Bravo, B1, 27, null]
[Bravo, B1, 28, null]
[Bravo, B1, 29, null]
[Bravo, B1, 30, null]
[Bravo, B1, 31, null]
[Bravo, B1, 32, null]
[Bravo, B1, 33, null]
[Bravo, B1, 34, null]
[Bravo, B1, 35, null]
[Bravo, B1, 36, null]
[Bravo, B1, 37, null]
[Bravo, B1, 38, null]
[Bravo, B1, 39, null]
[Bravo, B1, 40, null]
[Bravo, B1, 41, null]
[Bravo, B1, 42, null]
[Bravo, B1, 43, null]
[Bravo, B1, 44, null]
[Bravo, B1, 45, null]
[Bravo, B1, 46, null]
[Bravo, B1, 47, null]
[Bravo, B1, 48, null]
[Bravo, B1, 49, null]
[Bravo, B1, 50, null]
[Bravo, B1, 51, null]
[Bravo, B1, 52, null]
[Bravo, B1, 53, null]
[Bravo, B1, 54, null]
[Bravo, B1, 55, null]
[Bravo, B1, 56, null]
[Bravo, B1, 57, null]
[Bravo, B1, 58, null]
[Bravo, B1, 59, null]
[Bravo, B1, 60, null]
[Bravo, B2, 1, null]
[Bravo, B2, 2, null]
[Bravo, B2, 3, null]
[Bravo, B2, 4, null]
[Bravo, B2, 5, null]
[Bravo, B2, 6, null]
[Bravo, B2, 7, null]
[Bravo, B2, 8, null]
[Bravo, B2, 9, null]
[Bravo, B2, 10, null]
[Bravo, B2, 11, null]
[Bravo, B2, 12, null]
[Bravo, B2, 13, null]
[Bravo, B2, 14, null]
[Bravo, B2, 15, null]
[Bravo, B2, 16, null]
[Bravo, B2, 17, null]
[Bravo, B2, 18, null]
[Bravo, B2, 19, null]
[Bravo, B2, 20, null]
[Bravo, B2, 21, null]
[Bravo, B2, 22, null]
[Bravo, B2, 23, null]
[Bravo, B2, 24, null]
[Bravo, B2, 25, null]
[Bravo, B2, 26, null]
[Bravo, B2, 27, null]
[Bravo, B2, 28, null]
[Bravo, B2, 29, null]
[Bravo, B2, 30, null]
[Bravo, B2, 31, null]
[Bravo, B2, 32, null]
[Bravo, B2, 33, null]
[Bravo, B2, 34, null]
[Bravo, B2, 35, null]
[Bravo, B2, 36, null]
[Bravo, B2, 37, null]
[Bravo, B2, 38, null]
[Bravo, B2, 39, null]
[Bravo, B2, 40, null]
[Bravo, B2, 41, null]
[Bravo, B2, 42, null]
[Bravo, B2, 43, null]
[Bravo, B2, 44, null]
[Bravo, B2, 45, null]
[Bravo, B2, 46, null]
[Bravo, B2, 47, null]
[Bravo, B2, 48, null]
[Bravo, B2, 49, null]
[Bravo, B2, 50, null]
[Bravo, B2, 51, null]
[Bravo, B2, 52, null]
[Bravo, B2, 53, null]
[Bravo, B2, 54, null]
[Bravo, B2, 55, null]
[Bravo, B2, 56, null]
[Bravo, B2, 57, null]
[Bravo, B2, 58, null]
[Bravo, B2, 59, null]
[Bravo, B2, 60, null]
[Bravo, B3, 1, null]
[Bravo, B3, 2, null]
[Bravo, B3, 3, null]
[Bravo, B3, 4, null]
[Bravo, B3, 5, null]
[Bravo, B3, 6, null]
[Bravo, B3, 7, null]
[Bravo, B3, 8, null]
[Bravo, B3, 9, null]
[Bravo, B3, 10, null]
[Bravo, B3, 11, null]
[Bravo, B3, 12, null]
[Bravo, B3, 13, null]
[Bravo, B3, 14, null]
[Bravo, B3, 15, null]
[Bravo, B3, 16, null]
[Bravo, B3, 17, null]
[Bravo, B3, 18, null]
[Bravo, B3, 19, null]
[Bravo, B3, 20, null]
[Bravo, B3, 21, null]
[Bravo, B3, 22, null]
[Bravo, B3, 23, null]
[Bravo, B3, 24, null]
[Bravo, B3, 25, null]
[Bravo, B3, 26, null]
[Bravo, B3, 27, null]
[Bravo, B3, 28, null]
[Bravo, B3, 29, null]
[Bravo, B3, 30, null]
[Bravo, B3, 31, null]
[Bravo, B3, 32, null]
[Bravo, B3, 33, null]
[Bravo, B3, 34, null]
[Bravo, B3, 35, null]
[Bravo, B3, 36, null]
[Bravo, B3, 37, null]
[Bravo, B3, 38, null]
[Bravo, B3, 39, null]
[Bravo, B3, 40, null]
[Bravo, B3, 41, null]
[Bravo, B3, 42, null]
[Bravo, B3, 43, null]
[Bravo, B3, 44, null]
[Bravo, B3, 45, null]
[Bravo, B3, 46, null]
[Bravo, B3, 47, null]
[Bravo, B3, 48, null]
[Bravo, B3, 49, null]
[Bravo, B3, 50, null]
[Bravo, B3, 51, null]
[Bravo, B3, 52, null]
[Bravo, B3, 53, null]
结构如下:Alpha、Bravo、Charlie、Delta 和 Echo 是根节点,包含: (A1, A2, A3, A4) (B1, B2, B3, B4) (C1, C2, C3, C4) 等...然后每个都包含“n”个位置,每个数字包含一个人的名字。
我需要将其变成层次树结构。我尝试过以下方法:
Map<String, Set<String>> myNodes = new LinkedHashMap<String, Set<String>>();
for(String[] myArray : initialList) {
String previousNode = null;
for(String node : myArray) {
if(myNodes.get(node) == null) {
myNodes.put(node, new HashSet<String>());
}
if(previousNode != null) {
myNodes.get(previousNode).add(node);
}
previousNode = node;
}
}
但是输出如下,如您所见,这是错误的,而不是我正在寻找的内容(同样,只是完整输出的一个片段)。
Alpha : [A2, A1, A4, A3]
A1 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 19, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
1 : [null]
null : []
2 : [null]
null : []
3 : [null]
4 : [null]
5 : [null]
6 : [null]
7 : [null]
8 : [null]
9 : [null]
10 : [null]
11 : [null]
12 : [null]
13 : [null]
14 : [null]
15 : [null]
16 : [null]
17 : [null]
18 : [null]
19 : [null]
20 : [null]
21 : [null]
22 : [null]
23 : [null]
24 : [null]
25 : [null]
26 : [null]
27 : [null]
28 : [null]
29 : [null]
30 : [null]
31 : [null]
32 : [null]
33 : [null]
34 : [null]
35 : [null]
36 : [null]
37 : [null]
38 : [null]
39 : [null]
40 : [null]
41 : [null]
42 : [null]
43 : [null]
44 : [null]
45 : [null]
46 : [null]
47 : [null]
48 : [null]
49 : [null]
50 : [null]
51 : [null]
52 : [null]
53 : [null]
54 : [null]
A2 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 19, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
A3 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
55 : [null]
56 : [null]
57 : [null]
58 : [null]
59 : [null]
60 : [null]
A4 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
Bravo : [B4, B3, B2, B1]
B1 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
B2 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
B3 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
B4 : [35, 36, 33, 34, 39, 37, 38, 43, 42, 41, 40, 22, 23, 24, 25, 26, 27, 28, 29, 3, 2, 1, 7, 30, 6, 5, 32, 4, 31, 9, 8, 59, 58, 57, 56, 19, 55, 17, 18, 15, 16, 13, 14, 11, 12, 21, 20, 60, 49, 48, 45, 44, 47, 46, 10, 51, 52, 53, 54, 50]
这是使用 Map 和 LinkedHashMap,所以我也用 TreeMap 尝试过(尽管不确定这是否是我需要的):
TreeMap<String, Set<String>> myNodes = new TreeMap<String, Set<String>>();
for(String[] myArray : initialList) {
String previousNode = null;
for(String node : myArray) {
if(myNodes.get(node) == null) {
myNodes.put(node, new HashSet<String>());
}
if(previousNode != null) {
myNodes.get(previousNode).add(node);
}
previousNode = node;
}
}
但出现以下错误:
Exception in thread "main" java.lang.NullPointerException
at java.util.TreeMap.getEntry(TreeMap.java:324)
at java.util.TreeMap.get(TreeMap.java:255)
我需要它分层,如上所述。我很想准确地描述它应该输出什么,但说实话,我不确定,我只知道它需要有一个层次结构并转换为 JSON,如下所述。
此外,必须将其转换为以下格式的 JSON,因此请记住这一点(同样,实际输出要大得多,这只是一个结构示例:
{
"name":"Alpha",
"children":[
{
"name":"A1",
"children":[
{
"name":"1",
"children":[
{
"name":"null",
},
]
"name":"2",
"children":[
{
"name":"null",
},
]
"name":"3",
"children":[
{
"name":"null",
},
]
},
"name":"A2",
"children":[
{
"name":"1",
"children":[
{
"name":"null",
},
]
"name":"2",
"children":[
{
"name":"null",
},
]
"name":"3",
"children":[
{
"name":"null",
},
]
},
]
},
我很感激能得到的任何帮助,因为我真的很难过。谢谢!
最佳答案
尝试运行以下代码。
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
class JsonModel {
private String name;
private List<JsonModel> children;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public List<JsonModel> getChildren() {
return children;
}
public void setChildren(List<JsonModel> children) {
this.children = children;
}
public String toString(){
return "name: "+name + ", children: {"+children+"}";
}
}
public class Test{
public static void main(String a[])
{
ArrayList<String[]> initialList= new ArrayList<String[]>();
initialList.add(new String[]{"Alpha", "A1", "1", null});
initialList.add(new String[]{"Alpha", "A1", "2", null});
initialList.add(new String[]{"Alpha", "A2", "1", null});
initialList.add(new String[]{"Alpha", "A2", "2", null});
initialList.add(new String[]{"Beta", "A1", "1", null});
initialList.add(new String[]{"Beta", "A1", "2", null});
initialList.add(new String[]{"Beta", "A2", "1", null});
initialList.add(new String[]{"Beta", "A2", "2", null});
ArrayList<JsonModel> returnList = new ArrayList<JsonModel>();
HashMap<String,HashMap<String,JsonModel>> tempMap = new HashMap<String, HashMap<String,JsonModel>>();
HashMap<String,JsonModel> tempMapOuterMost = new HashMap<String, JsonModel>();
// eg. 1,null
JsonModel layer3Child = null;
// eg. A1,{}
JsonModel layer2Child = null;
// eg. Alpha,{}
JsonModel layer1Child = null;
for(String[] myArray: initialList){
// to set inner most object eg. 1,null
layer3Child = new JsonModel();
layer3Child.setName(myArray[2]);
JsonModel layer4Child = new JsonModel();
layer4Child.setName("PersonName");
ArrayList<JsonModel> layer4Children = new ArrayList<JsonModel>();
layer4Children.add(layer4Child);
layer3Child.setChildren(layer4Children);
// getting object of outermost model eg. Alpha,{}
if (tempMap.containsKey(myArray[0])){
layer1Child = tempMapOuterMost.get(myArray[0]);
} else {
layer1Child = new JsonModel();
layer1Child.setName(myArray[0]);
layer1Child.setChildren(new ArrayList<JsonModel>());
returnList.add(layer1Child);
tempMapOuterMost.put(myArray[0], layer1Child);
tempMap.put(myArray[0], new HashMap<String,JsonModel>());
}
// getting the object at layer 2 eg. A1,{}
if (tempMap.get(myArray[0]).containsKey(myArray[1])){
layer2Child = tempMap.get(myArray[0]).get(myArray[1]);
} else {
layer2Child = new JsonModel();
layer2Child.setName(myArray[1]);
layer2Child.setChildren(new ArrayList<JsonModel>());
layer1Child.getChildren().add(layer2Child);
tempMap.get(myArray[0]).put(myArray[1], layer2Child);
}
layer2Child.getChildren().add(layer3Child);
}
System.out.println(returnList);
}
}
关于java - 从数组生成树结构 Java,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28971926/
我正在尝试使用以下 keytool 命令为我的应用程序生成 keystore : keytool -genkey -alias tomcat -keystore tomcat.keystore -ke
编辑:在西里尔正确解决问题后,我注意到只需将生成轴的函数放在用于生成标签的函数下面就可以解决问题。 我几乎读完了 O'Reilly 书中关于 D3.js 的教程,并在倒数第二页上制作了散点图,但是当添
虽然使用 GraphiQL 效果很好,但我的老板要求我实现一个用户界面,用户可以在其中通过 UI 元素(例如复选框、映射关系)检查呈现给他们的元素并获取数据,这样做将为该人生成 graphql 输入,
我尝试在 Netbean 6.8 中使用 ws-import 生成 Java 类。我想重新生成 jax-ws,因为在 ebay.api.paypalapi 包中发现了一个错误(我认为该错误是由于 Pa
我有一个 perl 脚本,它获取系统日期并将该日期写入文件名。 系统日期被分配给 TRH1 变量,然后它被设置为一个文件名。 $TRH1 =`date + %Y%m%d%H%M`; print "TR
我是 Haskell 的新手,需要帮助。我正在尝试构建一种必须具有某种唯一性的新数据类型,因此我决定使用 UUID 作为唯一标识符: data MyType = MyType { uuid ::
我制作了一个脚本,它可以根据 Mysql 数据库中的一些表生成 XML。 该脚本在 PHP 中运行。 public function getRawMaterials($apiKey, $format
所以这是我的项目中的一个问题。 In this task, we will use OpenSSL to generate digital signatures. Please prepare a f
我在 SAS LIFEREG 中有一个加速故障时间模型,我想绘制它。因为 SAS 在绘图方面非常糟糕,我想实际重新生成 R 中曲线的数据并将它们绘制在那里。 SAS 提出了一个尺度(在指数分布固定为
我正在为 Django 后端制作一个样板,并且我需要能够使它到达下一个下载它的人显然无法访问我的 secret key 的地方,或者拥有不同的 key 。我一直在研究一些选项,并在这个过程中进行了实验
我正在创建一个生成采购订单的应用程序。我可以根据用户输入的详细信息创建文本文件。我想生成一个看起来比普通文本文件好得多的 Excel。有没有可以在我的应用程序中使用的开源库? 最佳答案 目前还没有任何
我正在尝试使用 ScalaCheck 为 BST 创建一个 Gen,但是当我调用 .sample 方法时,它给了我 java.lang.NullPointerException。我哪里错了? seal
已关闭。此问题需要 debugging details 。目前不接受答案。 编辑问题以包含 desired behavior, a specific problem or error, and the
我尝试编写一些代码,例如(在verilog中): parameter N = 128; if (encoder_in[0] == 1) begin 23 binary_out = 1;
我正忙于在 Grails 项目中进行从 MySQL 到 Postgres 的相当复杂的数据迁移。 我正在使用 GORM 在 PostGres 中生成模式,然后执行 MySQL -> mysqldump
如何使用纯 XSLT 生成 UUID?基本上是寻找一种使用 XSLT 创建独特序列的方法。该序列可以是任意长度。 我正在使用 XSLT 2.0。 最佳答案 这是一个good example 。基本上,
我尝试安装.app文件,但是当我安装并单击“同步”(在iTunes中)时,我开始在设备上开始安装,然后停止,这是一个问题,我不知道在哪里,但我看到了我无法解决的奇怪的事情: 最佳答案 似乎您没有在Xc
自从我生成 JavaDocs 以来已经有一段时间了,我确信这些选项在过去 10 年左右的时间里已经得到了改进。 我能否得到一些有关生成器的建议,该生成器将输出类似于 .Net 文档结构的 JavaDo
我想学习如何生成 PDF,我不想使用任何第三方工具,我想自己用代码创建它。到目前为止,我所看到的唯一示例是我通过在第 3 方 dll 上打开反射器查看的代码,以查看发生了什么。不幸的是,到目前为止我看
我正在从 Epplus 库生成 excel 条形图。 这是我成功生成的。 我的 table 是这样的 Mumbai Delhi Financial D
我是一名优秀的程序员,十分优秀!