Skip to content

Instantly share code, notes, and snippets.

@khayyamsaleem
Last active September 22, 2019 21:53
Show Gist options
  • Save khayyamsaleem/37fdd17ef7278c512b9578e759da73a7 to your computer and use it in GitHub Desktop.
Save khayyamsaleem/37fdd17ef7278c512b9578e759da73a7 to your computer and use it in GitHub Desktop.
public class BigInteger {
DigitNode front;
private static class DigitNode {
int digit;
DigitNode next;
public DigitNode(int digit) {
this.digit = digit;
this.next = null;
}
public DigitNode(int digit, DigitNode next) {
this.digit = digit;
this.next = next;
}
public String toString(){
DigitNode cur = this;
String out = "";
while (cur != null) {
out += "(" + cur.digit + ") -> ";
}
return out;
}
}
public String toString() {
return this.front.toString();
}
public static void main (String[] args) {
BigInteger b = new BigInteger();
b.front = new DigitNode(5);
b.front.next = new DigitNode(4);
b.front.next.next = new DigitNode(3);
b.front.next.next.next = new DigitNode(2);
b.front.next.next.next.next = new DigitNode(1);
System.out.println(b);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment