Q:

Java Program to insert elements into the linked list at the first and last position

0

Program to insert elements into the linked list at the first and last position.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import java.util.*;
public class demo1 
{
 public static void main(String[] args)
 {
  LinkedList<String> link_list = new LinkedList<String>();
  link_list.add("C#");
  link_list.add("C++");
  link_list.add("Python");
  link_list.add("Perl");
  link_list.add("Ruby");
  System.out.println("Original linked list:" + link_list);    
  
  link_list.addFirst("Java");
  link_list.addLast("HTML");
  System.out.println("Final linked list:" + link_list);  
 }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now