Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


almuhnnad
hep me
1 Answer(s)      4 years and 7 months ago
Posted in : Java Interview Questions


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

Advertisement
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
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
Advertisements
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:- rohit11tripathi@gmail.com 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  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
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  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..  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...  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
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...  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
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
the order, Fourth button is Find length of text. and there are panels. Please help me
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
sends me email
sends me email  How do I create a link that sends me email
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
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
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
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
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
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
Tell me - Struts
Directory Structure with example program Execution  Tell me the Directory Structure with example program Execution
Tell me - Struts
Struts tutorial to learn from beginning   Tell me, how can i learn the struts from beginning
 

 

 

DMCA.com