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
scoundrel [369]
3 years ago
5

Write a class that can make comparisons between the efficiency of the common methods from the List interface in the ArrayList an

d LinkedList classes such as add, get, and remove. Use the polymorphic-variable technique described above to write the class so that it only knows it is performing its tests on objects of the interface type List rather than on the concrete types ArrayList and LinkedList. Use large lists of objects for the tests, to make the results significant. You can use the currentTimeMillis method of theSystem class for getting hold of the start and finish time of your test methods.

Computers and Technology
1 answer:
Alika [10]3 years ago
6 0

Answer:

Check the explanation

Explanation:

CODE TO COPY:

File: ArrayListVsLinkedlIst.java

// ArrayListVsLinkedlIst class implementation

import java.util.*;

public class ArrayListVsLinkedlIst

{

  public static void main(String[] args)

  {

      // create a constant for the size of each list

      final int SIZE = 300000;

      // create the required objects

      List<Integer> aList = new ArrayList<Integer>();

      List<Integer> lList = new LinkedList<Integer>();

      // declare the required variables

      long start, end;

      int i;

      // comparison between the efficiency of the add() method

      // from the ArrayList and LinkedList classes

      System.out.println("Time in milliseconds to add " + SIZE

              + " numbers to each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.add(i);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.add(i);

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

      // comparison between the efficiency of the get() method

      // from the ArrayList and LinkedList classes

      System.out.println("\nTime in milliseconds to get " + SIZE

              + " numbers from each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.get(i);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.get(i);

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

      // comparison between the efficiency of the remove() method

      // from the ArrayList and LinkedList classes

      System.out.println("\nTime in milliseconds to remove " + SIZE

              + " numbers from each list ...");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          aList.remove(0);

      }

      end = System.currentTimeMillis();

      System.out.println("ArrayList: " + (end - start) + " ms");

      start = System.currentTimeMillis();

      for (i = 0; i < SIZE; i++)

      {

          lList.remove(0);          

      }

      end = System.currentTimeMillis();

      System.out.println("LinkedList: " + (end - start) + " ms");

  }

} // end of ArrayListVsLinkedlIst class

The screenshot and output images can be seen below.

You might be interested in
A small group of travelers is meeting inside an ancient building, and the travelers need access to the Internet using their mobi
artcher [175]

Answer:

c. Mobile hotspot

Explanation:

A mobile hotspot is a hotspot that is to be activated by turning on the WiFI hotspot. It is used to share the cellular data to the laptop, computer system and the mobile devices who do not have an internet connection

Since in the question, it is mentioned that the one traveler has an unlimited cellular data plan and a consistent strong signal

So the mobile hotspot should be used to provide internet service to the group.

6 0
3 years ago
In social networking websites such as twitter, people leave narrow minded and subjective remarks and upload unacceptable videos.
koban [17]
The advice is That you Message Them To remind Them Those Type of posts are not appropriate if people on social Media say bad Things To you you block Them if people don’t Treat you nice
8 0
3 years ago
Which of the following is not a computer application?
Elan Coil [88]
Answer:C.apple Osx
Answer C
7 0
3 years ago
Read 2 more answers
____________ define the allowable interactions between subjects and objects. credentials responsibilities procedures access cont
liq [111]
<span>Access controls define the allowable interactions between subjects and objects.
</span>They define contains rules which govern the interactions between subjects and objects and permissions subjects can grant to other subjects. The interactions between subjects and objects can be:<span> take, grant, create, remove...</span>
8 0
3 years ago
Read 2 more answers
Match these items. 1 . Naturalization Act stated that a foreigner had to live in the United States fourteen years to become a ci
Romashka-Z-Leto [24]

Answer and Explanation:

1. Naturalization Act:

  • Expressed that an outsider needed to live in the United States fourteen years to turn into a native.

2. Judiciary Act:

  • It was an effort to save Federalist standards

3. Sedition Act:

  • Approved fines up to $5,000 and detainment for ruining the legislature.

4. Alien Act:

  • Allowed the President to oust aliens or outsiders whom he judged "risky"

5. Alien and Sedition Acts:

  • Constrained through Congress by the Federalists.

6. Alien Enemies Act:

  • Allowed the President to detain or extradite hazardous outsiders or aliens in time of war
8 0
3 years ago
Other questions:
  • ________ is the information about a file.
    7·1 answer
  • A series of inventions led to the creation of the electronic digital computer shortly after this war..
    12·1 answer
  • Encryption has a remarkably long and varied history. Spies have been using it to convey secret messages ever since there were se
    7·1 answer
  • Assuming that a year has 365 days, write a class named DayOfYear that takes an integer representing a day of the year and transl
    6·1 answer
  • Micheal is the project manager in a company. He wants his organization to use technology for higher revenue and productivity. Wh
    13·1 answer
  • Write a program that reads an integer, a list of words, and a character. The integer signifies how many words are in the list. T
    6·1 answer
  • Can you see the processing step yes or no
    8·2 answers
  • in windows 10, what feature is used to locate and launch software or applications installed on your device?
    8·1 answer
  • What standards organization maintains the ethernet standard?.
    12·1 answer
  • What is the purpose of each component ?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!