hep me

hep me

Write a program that merges two ordered linked list of integers into one ordered linked list of integers. Method merge should receive references to each of the lists and return a reference to the merged list
View Answers

June 5, 2010 at 11:59 AM

Hi Friend,

Try the following code:

import java.util.*;

class MergeLinkedLists{
public static void main(String[] args) {
LinkedList<Integer> list1=new LinkedList<Integer>();
list1.add(1);
list1.add(2);

LinkedList<Integer> list2=new LinkedList<Integer>();
list2.add(3);
list2.add(4);

LinkedList<Integer> link=new LinkedList<Integer>(list1);
link.addAll(list2);
ListIterator li = link.listIterator();
while (li.hasNext()) {
System.out.println(li.next());
}

}
}

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
hep me - Java Interview Questions
hep me  Write a program that merges two ordered linked list of integers into one ordered linked list of integers. Method merge should receive references to each of the lists and return a reference to the merged list  Hi
ModuleNotFoundError: No module named 'matplotlib-hep'
ModuleNotFoundError: No module named 'matplotlib-hep'  Hi, My... named 'matplotlib-hep' How to remove the ModuleNotFoundError: No module named 'matplotlib-hep' error? Thanks   Hi, In your python
Advertisements
ModuleNotFoundError: No module named 'scikit-hep'
ModuleNotFoundError: No module named 'scikit-hep'  Hi, My Python... 'scikit-hep' How to remove the ModuleNotFoundError: No module named 'scikit-hep' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'hep-ml'
ModuleNotFoundError: No module named 'hep-ml'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hep-ml' How to remove the ModuleNotFoundError: No module named 'hep-ml'
ModuleNotFoundError: No module named 'hep-rfm'
ModuleNotFoundError: No module named 'hep-rfm'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hep-rfm' How to remove the ModuleNotFoundError: No module named 'hep-rfm
ModuleNotFoundError: No module named 'hep-spt'
ModuleNotFoundError: No module named 'hep-spt'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'hep-spt' How to remove the ModuleNotFoundError: No module named 'hep-spt
ModuleNotFoundError: No module named 'scikit-hep-testdata'
ModuleNotFoundError: No module named 'scikit-hep-testdata'  Hi, My... named 'scikit-hep-testdata' How to remove the ModuleNotFoundError: No module named 'scikit-hep-testdata' error? Thanks   Hi
ModuleNotFoundError: No module named 'hep-rest-api'
ModuleNotFoundError: No module named 'hep-rest-api'  Hi, My Python... 'hep-rest-api' How to remove the ModuleNotFoundError: No module named 'hep-rest-api' error? Thanks   Hi, In your python
help me
help me  i have done as u directed but nothing happens gud to me..... . i am using netbeans is that matter at all help me and take me out from trouble where to store jfree api to use it for j2ee based project
help me
help me  hi sir pls tell me how to use ajax form validatin from very simple way with two ot three text field pls help me use ajax in php my email id is:- [email protected] pls sir give me some vasic information i know
help me
help me  please send me the java code to count the number of similar words in given string and replace that word with new one
help me..
help me..   what are the component needed by grid computing, cloud computing and ubiquitous computing? discuss about the security of above computing. difference between that 3 computing
help me
help me  HI. Please help me for doing project. i want to send control from one jsp page to 2 jsp pages... is it possible? if possible how to do
Remember Me
Remember Me  How to Create a PHP AutoLogin ('Remember Me') Feature using Cookies????   Hi Friend, Please visit the following links: http://www.roseindia.net/sql/mysql-example/Login-php.shtml http://www.roseindia.net
help me...
help me...  Write a program that inputs four words and them displays all possible permutations of the words. So, for example, if the words mad, dog, bites and man are entered, then the following are output : man bites mad dog
help me..
help me..  Write a program that inputs four words and them displays all possible permutations of the words. So, for example, if the words mad, dog, bites and man are entered, then the following are output : man bites mad dog mad
help me
help me  MY GLASSFISH SERVER NOT START PROPERLY help me warning shows DPL5404:Specification-Version for the optional package [ GNUJAXP ] in the jarfile [ C:\Program Files\Java\jdk1.7.0_02\jre\lib\ext\gnujaxp.jar
help me...
help me...  there is the picture given - cat - dog - rabbit - mouse a. create a class name b. create its attributes (at least 3 attributes) : species, size, leg c. create its methods ( at least 3 methods) : walk, eat, sleep
help me
button, and nationality I'm using dropdown list. Please help me. your kindness
help me..
help me..  Design and write a class named Person and its two subclasses named Student and Employee. Make Lecturer and Admin subclasses of Employee. A person has a name, address, phone number and email address. A student has
help me
help me
help me
the order, Fourth button is Find length of text. and there are panels. Please help me
sends me email
sends me email  How do I create a link that sends me email
help me - WebSevices
help me   help me with the principals of designing agood websites and i can start
help me - WebSevices
help me   help me with the principals of designing agood websites and i can start
ModuleNotFoundError: No module named 'me'
ModuleNotFoundError: No module named 'me'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'me' How to remove the ModuleNotFoundError: No module named 'me' error
Tell me - Struts
Directory Structure for Struts  Tell me the Directory Structure for Struts
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
pls help me it urgent
pls help me it urgent  hey, pls help me i want to know that can we call java/.bat file from plsql/proceudre /trigger
help me out...!!!!
help me out...!!!!  i have to make a project on console based application in java.. so can anyone guide me with some gd ideas that can be implemented
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
plz give me answer
plz give me answer   description about string class methods   Java string methods
Reply Me - Java Beginners
Reply Me  Hi, This is not correct url please send me again coorect url
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
Show me the code for that
Show me the code for that  JVM on my machine? And how do I know whether its working
Tell me - Struts
Struts tutorial to learn from beginning   Tell me, how can i learn the struts from beginning
Tell me - Struts
Directory Structure with example program Execution  Tell me the Directory Structure with example program Execution
Help me quickly plz??
Help me quickly plz??  Can you help me to write code quickly this code is a java code take input as double and should use command line arguments and enhanced for statement then find the combine of the numbers plz help quickly
Reply me - Java Beginners
Reply me  If u r not understood my just posted question plz let me know  Hi Ragini, Please specify your requirements in detail. It would be good for me to provide you the solution if problem is clear. And also
plz give me answer
plz give me answer  Discuss & Give brief description about string class methods   Java string methods
pls help me with this question
pls help me with this question  how to write a program in C++ using encapsulation,polymorphism,inheritance and abstraction?(all these concepts should come in a single program
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
Pls help me with strings
Pls help me with strings  To reverse a every other word in a string. Example :- If the input is "This is a line of message" the output should be "sihT is a line fo message
Pls help me with strings
Pls help me with strings  To reverse a every other word in a string. Example :- If the input is "This is a line of message" the output should be "sihT is a line fo message

Ads