Answer:
Java program given below
Explanation:
import java.util.*;
import java.io.*;
public class Lineeditor
{
 private static Node head;
  
 class Node
 {
  int data;
  Node next;
  public Node()
  {data = 0; next = null;}
  public Node(int x, Node n)
  {data = x; next =n;}
 }
  
 public void Displaylist(Node q)
  {if (q != null)
        {  
         System.out.println(q.data);
          Displaylist(q.next);
        }
  }
  
 public void Buildlist()
   {Node q = new Node(0,null);
        head = q;
        String oneLine;
        try{BufferedReader indata = new
                  BufferedReader(new InputStreamReader(System.in)); // read data from terminals
                        System.out.println("Please enter a command or a line of text: ");  
           oneLine = indata.readLine();   // always need the following two lines to read data
          head.data = Integer.parseInt(oneLine);
          for (int i=1; i<=head.data; i++)
          {System.out.println("Please enter another command or a new line of text:");
                oneLine = indata.readLine();
                int num = Integer.parseInt(oneLine);
                Node p = new Node(num,null);
                q.next = p;
                q = p;}
        }catch(Exception e)
        { System.out.println("Error --" + e.toString());}
  }
 public static void main(String[] args)
 {Lineeditor mylist = new Lineeditor();
  mylist.Buildlist();
  mylist.Displaylist(head);
 }
}