1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
olasank [31]
3 years ago
8

Write a method intersect that accepts two sorted array lists of integers as parameters and returns a new list that contains only

the elements that are found in both lists.
Computers and Technology
1 answer:
Korvikt [17]3 years ago
7 0

Answer:

Explanation:

The following code is written in Java. It creates a function called equalElements that takes two ArrayList of integers as parameters loops through both of them to find the elements that are equal in both and then adds those elements to a new ArrayList called repeated. Then the ArrayList is returned to the user.

public static ArrayList<Integer> equalElements(ArrayList<Integer> arrOne, ArrayList<Integer> arrTwo) {

                       ArrayList<Integer> repeated = new ArrayList<>();

               for (int x: arrOne) {

                       for (int i: arrTwo) {

                               if (x == i) {

                                   repeated.add(x);

                                   break;

                               }

                       }

               }

               

               return repeated;

}

You might be interested in
Which of the following assumes that the repair will happen just as the technician stated?
kipiarov [429]
A (filling out carachts
3 0
3 years ago
The _____ lists all of the fields that are available in a table.
crimeas [40]

What are the other options? Is this multiple choice or just fill in the blank

7 0
3 years ago
Write a program that asks length,breadth and height of a room and calculate its volume​
marta [7]

Answer:

cls

Input"enter length";l

Input"enter breadth";b

Input"enter height";h

v=l*b*h

print"the volume is";v

end

Explanation:

hope you got it

6 0
3 years ago
Annabella was giving a presentation to a group of 20 real estate agents on
podryga [215]

Anticipate questions.

3 0
3 years ago
Read 2 more answers
What form of infrastructure improved trade and communication among Roman cities?
grigory [225]

Answer:

aqueducts

Explanation:

5 0
3 years ago
Other questions:
  • When you define a table's primary key, the dbms automatically creates a(n) _____ index on the primary key column(s) you declared
    14·1 answer
  • Please I need help!!!!!!!
    14·2 answers
  • Which would be included in a SaaS platform?<br><br> A.data link<br> B.IaaS<br> C.Java<br> D.vb.net
    5·1 answer
  • Write a C function which takes three parameters which are the cost for an item in a grocery store, the quantity to buy, and the
    12·2 answers
  • What technique is used when setup times at a workstation are sequence dependent?
    15·1 answer
  • What is the device that is non-volatile sometime called external memory?<br>​
    15·1 answer
  • Which benefit does the cloud provide to star-up companies without access to large funding?
    11·1 answer
  • Que segnifica mmmju?​
    15·1 answer
  • What 3 types of data can be entered in a spreadsheet
    14·1 answer
  • Discuss any 4 differences between first and second generation of programming languages <br>​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!