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
dedylja [7]
3 years ago
6

Create two Lists, one is ArrayList and the other one is LinkedList and fill it using 10 state names (e.g., Texas). Sort the list

and print it, and then shuffle the lists at random. Please use java.util.Collections class to do sorting and shuffling.
Computers and Technology
1 answer:
OlgaM077 [116]3 years ago
4 0

Answer:

The program to this question can be given as:

Program:

import java.util.*; //import package

public class Main //define class main.

{

public static void main(String[] args) //define main method.

{

ArrayList<String> AL1 = new ArrayList<>(); //create ArrayList object AL1.

LinkedList<String> LL2 = new LinkedList<>(); //create LinkedList object LL2.

AL1.addAll(Arrays.asList("Bihar","Andhra Pradesh","Assam","Chhattisgarh","Arunachal Pradesh","Goa","west bangol","Gujarat","Jharkhand","Karal"));//add elements in ArrayList

LL2.addAll(Arrays.asList("Bihar","Andhra Pradesh","Assam","Chhattisgarh","Arunachal Pradesh","Goa","west bangol","Gujarat","Jharkhand","Karal"));//add elements in LinkedList

Collections.sort(AL1); //sort ArrayList

Collections.sort(LL2); //sort LinkedList

System.out.println("Sorting in ArrayList and LinkedList elements :");

System.out.println("ArrayList :\n" +AL1);

System.out.println("LinkedList :\n"+LL2);

Collections.shuffle(AL1); //shuffle ArrayList

Collections.shuffle(LL2); //shuffle LinkedList

System.out.println("shuffling in ArrayList and LinkedList elements :");

System.out.println("shuffle ArrayList:\n"+AL1);

System.out.println("shuffle LinkedList:\n"+LL2);

}

}

Output:

Sorting in ArrayList and LinkedList elements :

ArrayList :

[Andhra Pradesh, Arunachal Pradesh, Assam, Bihar, Chhattisgarh, Goa, Gujarat, Jharkhand, Karal, west bangol]

LinkedList :

[Andhra Pradesh, Arunachal Pradesh, Assam, Bihar, Chhattisgarh, Goa, Gujarat, Jharkhand, Karal, west bangol]

shuffling in ArrayList and LinkedList elements :

shuffle ArrayList:

[Chhattisgarh, Jharkhand, Gujarat, Goa, west bangol, Andhra Pradesh, Arunachal Pradesh, Assam, Karal, Bihar]

shuffle LinkedList:

[Assam, Karal, Jharkhand, Bihar, Goa, Arunachal Pradesh, Andhra Pradesh, Gujarat, west bangol, Chhattisgarh]

Explanation:

In the above java program firstly we import the package then we define the main method in this method we create the ArrayList and LinkedList object that is AL1 and LL2.

In ArrayList and LinkedList we add state names then we use the sort and shuffle function. and print all values.

  • The sort function is used to sort array by name.
  • The shuffle function is used to Switching the specified list elements randomly.

You might be interested in
Grid computing takes advantage of the available 75% of unused processing power of a computer and links thousands of individual c
11111nata11111 [884]

Answer:

The answer is "Virtual supercomputer"

Explanation:

A supercomputer is a machine with or close to a maximum fastest operating output. It commonly used in science and engineering systems, that have to manage or calculate massive server numbers.

  • A virtual supercomputer is also known as a cloud device.  
  • It gives you to the platform, and provides you a built-in cloud environment, by mixing different virtual servers.
  • Its rebellion is to be used by individuals.

3 0
4 years ago
How does a hard drive work
IgorC [24]
You just have to put it into a computer and a file is gonna come up
7 0
3 years ago
Read 2 more answers
What is a graphical user interface (GUI)?
o-na [289]

The answer is D - A user-friendly computer program that allows the user to point and click on icons to make the computer function.


4 0
4 years ago
You just purchased a single license for the latest Microsoft Office Suite. Your friend has asked to borrow the CD, so he can ins
TiliK225 [7]

Answer:

B

Explanation:

No, this would be piracy. If he would want to install it, he would have to buy it himself.

Hope this helps :D

6 0
3 years ago
How to change default search engine in internet explorer 10?
ser-zykov [4K]
Settings > view advanced settings > change search engine > Google search > set as default
7 0
3 years ago
Other questions:
  • What setting must be enabled to view data in Demographics and Interests Reports? Content Grouping Advertising features User perm
    13·1 answer
  • Naseer has inserted an image into his document but needs the image to appear on its own line.
    14·2 answers
  • The actual database of Active Directory shared resources is stored on one or more computers designated as:
    6·1 answer
  • Which network component connects a device with the transmission media?
    9·1 answer
  • Egovernment involves the use of strategies and technologies to transform government by improving the delivery of services and en
    7·1 answer
  • It is always safe to enter personal information into a pop-up window. true or false.
    13·1 answer
  • Can anyone help me with a mental ability work plzz
    12·1 answer
  • In ANSI standard C(1989) code - this is what we are teaching- declarations can occur in a for statementas in
    5·1 answer
  • I have this questions i need to make it in a report format pages of atleast 3 pages and maximum of 5 pages​
    7·1 answer
  • Which of the following controls computer memory?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!