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
Your mom wants to start using some type of cloud storage so that she can access
Whitepunk [10]
A cloud storage she can use for her business files without having to remote into another machine is Dropbox
4 0
4 years ago
Read the problem listed below. Formulate a Decomposition or Outline of the problem. Determine if you have seen this problem befo
SashulF [63]

URL where the media can be found;

the description of the type of media used in the example;

an analysis of the media piece in relation to the best practices discussed in this lesson, which answers these questions:

Does the piece illustrate best practices?

Which are best represented?

What point do you feel the company

7 0
3 years ago
Given two variables firstInClass and secondInClass which have already been associated with values, write code which swaps the va
valentina_108 [34]

Answer:

Following are the code in the python language

if firstInClass.startswith("Pat") and secondInClass.startswith("Wei"):  #check the #condition

   firstInClass, secondInClass = secondInClass, firstInClass #swap value

Explanation:

Following are the description of statement

  • Firstly we check the condition the string start with pat with the string start with the Wei string along with the and operator with them .
  • If the condition is true then it executed the block of if statement means executed the statement inside the if block .It means it swap the statement without assigning the value .
8 0
4 years ago
Lee finishes entering all the data. Next, he wants to format the header row so it is easier to read and stands out from the rest
dangina [55]

Answer:

A: Add shading to the top row

B: Change the style of the table

Explanation:

Just got the question myself and got the answer from it

6 0
3 years ago
television broadcasts were originally delivered by using which technology? ethernet wireless coaxial cable broadband
laiz [17]

Television broadcasts were originally delivered by using:

  • Ethernet
  • Coaxial cable
  • [Wireless] or  Broadband

<h3>What is Ethernet is used for?</h3>

Ethernet is known to be a kind of network or services that is often used to link two or more devices in a network.

This is known to be very  popular kind of network connection. It is known to be used in  local networks by specific organizations such as offices, school campuses and  it is used often for Television broadcasts.

Therefore,  Television broadcasts were originally delivered by using:

  • Ethernet
  • Coaxial cable
  • [Wireless] or  Broadband

Learn more about Ethernet from

brainly.com/question/1637942

#SPJ1

7 0
2 years ago
Other questions:
  • Alright, don't judge me, this is a question that involves my Childhood game PvZ GW 2. So I noticed mods and stuff that get uploa
    12·2 answers
  • What tab should you choose to locate the copy and paste tool?
    10·2 answers
  • Explain how software is distinct from hardware.
    8·2 answers
  • An administrator has several cables plugged into a patch panel and needs to determine which one comes from a specific port. Whic
    15·1 answer
  • Evaluating algebraic expressions 8(x+2)when x =6
    7·1 answer
  • Do you think<br> brain uploading<br> is a good idea?
    7·1 answer
  • Is anyone a robIox moderator?
    13·2 answers
  • I have no idea what I’m doing and this is due in 45 minutes
    7·1 answer
  • What is a functional organisation? and how it functions​?
    12·1 answer
  • 1 the background image on the desktop of computer is called
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!