Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

public static void Main ( ArrayList list 1 , ArrayList list 2 ) { HashMap result = new HashMap < > ( ) ; for

public static void Main(ArrayList list1, ArrayList list2){
HashMap result = new HashMap<>();
for (int i =0; i < list1.size(); i++){
String s1= list1.get(i);
String s2= list2.get(i);
if (!result.containsKey(s1)){
result.put(s1, s2);
} else if (!result.containsKey(s2)){
result.put(s2, s1);
} else {
result.put(s1+ s2, s1);
}
}
System.out.println(result);
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David M. Kroenke

12th Edition International Edition

1292023422, 978-1292023427

More Books

Students also viewed these Databases questions