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




Have Programming Question? Ask it here!
 
 
 


almuhnnad
hep me
1 Answer(s)      4 years and 2 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.  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
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
Show me the code for that
Show me the code for that  JVM on my machine? And how do I know whether its working
help me - JSP-Servlet
help me   how to open one compiled html file by clicking one button from jsp
Pls anyboby tell me...
Pls anyboby tell me...  which book easy to learn spring
Reply Me - Java Beginners
Reply Me  Hi, This is not correct url please send me again coorect url
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
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
Guide me to learn Flex
Guide me to learn Flex  Guidance to learn Flex Thanks in Advance. Kamal   Please visit the following link: Flex Tutorials
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
plz give me answer
plz give me answer  Discuss & Give brief description about string class methods   Java string methods
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 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 to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
Reply me soon.........
Reply me soon.........  Any body plzz help.....how to get d checked details from previous page to current page and den insert into table
Please give me the answer.
"int a=08 or 09" its giving compile time error why   "int a=08 or 09" its giving compile time error why ? can any one give me the answer of this please
Help me plzz
Help me plzz  Hello Roseindia.... I need ur help urgently... I am... project not web project so kindly provide me a help.... It will be good for me if u provide me all required files like; strtus.xml web.xml 2 Jsp pages thnx
help me 3
help me 3  write aprogram in java using two dimentional array.Accept the two dimentional array from the user and perform addition and subtraction of these two arrays and display the result for each add and subtruct
help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
Advertisements
 

 

 

DMCA.com