-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBuildAppend.java
48 lines (40 loc) · 968 Bytes
/
BuildAppend.java
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
42
43
44
45
46
47
public class BuildAppend {
public BuildAppend next;
/**
* Build list appList with length n
* Then build list with length n
* Then append appList to list
*
* @author Joel Beckmann
*/
public static void main(String[] args) {
int n = args.length;
BuildAppend list = append(n);
while (list.next != null) {
list = list.next;
}
}
public BuildAppend() {
this.next = null;
}
public static BuildAppend append(int length) {
BuildAppend al = build(length);
int i = 0;
return buildAppend(al, length);
}
public static BuildAppend build(int length) {
BuildAppend l = new BuildAppend();
if (length > 0) {
l.next = build(length - 1);
}
return l;
}
public static BuildAppend buildAppend(BuildAppend al, int length) {
if (length > 0) {
BuildAppend l = new BuildAppend();
l.next = buildAppend(al, length - 1);
return l;
}
return al;
}
}