title: Single LinkedList implementation using java
body: <p>I have the following code for a singly linked list, but the value I insert is made only once, how to make the user give say for example 5 values at different position?
  Is what I did right, and can anyone make it clear?</p>
  
  <pre><code>class Node1{
      private String data;
      private Node1 nextNode;
      public String getData() {
          return data;
      }
  
      public void setData(String data) {
          this.data = data;
          insertFirst(data);
      }
  
      public Node1 getNextNode() {
          return nextNode;
  
      }
      public void setNextNode(Node1 nextNode) {
          this.nextNode = nextNode;
          insert("deena",1);
      }
  
      public void insertFirst(String data){
  
          insert(data, 0);
  
      }
      public void insertLast(String data){
          // Logic for insert last
      }
      public void insert(String data, int position){
          System.out.println("data   "+data);
          System.out.println("position   "+position);
  
          }
  
      public static void main(String[] arg){
          String j;
          Node1 n = new Node1();
          System.out.println("Enter the name to be inserted");
          Scanner d=new Scanner(System.in);
          j=d.next();
          n.insertFirst(j);
          }
      }
  </code></pre>