Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- public class LinkedList {
- public static void main(String[] args) throws FileNotFoundException {
- IntegerDynamicNode base = null;
- IntegerDynamicNode temp = new IntegerDynamicNode();
- Scanner scan = new Scanner(new File("numbers.txt"));
- while(scan.hasNextInt()) {
- int Number = scan.nextInt();
- temp.payload = Number;
- temp.next = base;
- base = temp;
- }
- printList(base);
- }
- public static void printList(IntegerDynamicNode n) {
- System.out.println(n.payload);
- if (!(n.next == null)) printList(n.next);
- }
- }
- public class IntegerDynamicNode {
- public int payload;
- public IntegerDynamicNode next;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement