Skip to content

Instantly share code, notes, and snippets.

@martinschaef
Created January 17, 2017 17:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save martinschaef/0e8244f91670244e4569b366474bbf30 to your computer and use it in GitHub Desktop.
Save martinschaef/0e8244f91670244e4569b366474bbf30 to your computer and use it in GitHub Desktop.
Example from Sec 2
public class Maun {
public static class Node {
final Node next;
final int data;
public Node(Node next, int data) {
this.next = next;
this.data = data;
}
}
public static void main(String[] args) {
final int size = 10;
final int[] table = new int[size];
Node l1 = null;
Node l2 = null;
for (int i = 0; i < args.length; i++) {
int d = Integer.parseInt(args[i]);
if (d >= 0 && d < size) {
l1 = new Node(l1, d);
} else {
l2 = new Node(l2, d);
}
}
while (l1 != null) {
table[l1.data]++;
l1 = l1.next;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment