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
The __________ logical operator works best when testing a number to determine if it
inn [45]

Answer: && AND

Explanation:

 The logical AND operator works good during a testing the number for determining whether the given number is within the range. The && is the type of the Boolean operator and it is generally known as AND logical operator.

The given logical operator value is TRUE when both the operand in the Boolean value are true and otherwise it return FALSE. The AND logical operator value contain associativity from the left to right.

In the logical AND (&&) operator the given condition become TRUE when both operand in the logical operator are the non zero value.

3 0
3 years ago
Pls help I will give points
Brrunno [24]

Answer:

Desktop

Explanation:

3 0
3 years ago
Why can a "group by" or "order by" clause be expensive to process? What is the difference between a where and having clause?
Zielflug [23.3K]

Answer and Explanation:

Group by clause bunches every one of the information coming back from the question in the predetermined gatherings.  

Order by clause will arrange the information either in rising  or in dropping order depending on the section data or column data.  

It is certainly a lengthy from execution perspective.  

Envision that the quantity of columns returned by the question are millions and gathering and arranging information from this parcel takes bigger execution time.  

The procedure is a lot of equivalent to on the off chance that you are approached to arrange the precisely coordinating names in a populace measurements, it requires colossal measure of handling time to make sense of the precisely coordinating names and after that arranging them as needs be.

The distinction between where and having clause:

'Where' and having clause in SQL are utilized to indicate separating conditions.  

There is a little contrast between these two clause and is given as under:  

WHERE clause is utilized while getting data (lines or rows) from the table, and the information which clears the condition will only be considered into  the result set.

HAVING clause is later utilized to channel a data summary or gathered data.  

On the off chance that the two clauses show up in SQL question, where clause will execute at first and afterward having clause is executed on the groups that returns the group clause.

8 0
4 years ago
What three components should be included in a computer that is used to create TV commercials and music videos? (Choose three.
Vikki [24]

The three components is a specialized video card, large and fast hard drives and specialized audio card.

8 0
3 years ago
Read 2 more answers
The _______ command was developed by nicholas harbour of the defense computer forensics laboratory.
Lena [83]
Hi! The answer is dcfldd
3 0
3 years ago
Other questions:
  • Side mirror using convex mirror or concave mirror?​
    5·2 answers
  • Litmus-type test strips are used to test coolant for freeze protection and ?
    12·1 answer
  • Which practice represents the trait of effective communication?
    6·2 answers
  • The destination ip address is 164.109.27.233 subnet mask of 255.255.192.0 network address is
    12·1 answer
  • Andrew wants to create a website for his college. Which web-based programming language should he use?
    11·2 answers
  • Can you give me a long list of kid's cartoons
    15·1 answer
  • Who plays rocket league on xbox?
    15·2 answers
  • Modern Computers compared to earlier computers are
    10·1 answer
  • FIRST TO Answer for free brainlest. GOG GOGOGO
    14·2 answers
  • Which computer are used by mobile employees such as meter readers.​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!