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
Setler [38]
3 years ago
15

Write code to create a set with the following integers as members: 10, 20, 30, and 40.

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

Answer:

import java.util.*;  

public class Create_set

{

   public static void main(String args[])

   {

       Set<Integer> hset = new HashSet<Integer>(); //creating set using hashset of Integer type

       hset.add(10); //add method add members to set

       hset.add(20);

       hset.add(30);

       hset.add(40);

       System.out.println(hset); //printing the set

       

   }

}

OUTPUT :

[20,40,10,30]

Explanation:

The above code is implemented through java language. First a collection object is created using Set interface. Then that interface is implemented using Hashset class. As they are of generic datatype, Integer type is declared for this object. Then using add() method elements of the set are added and at last they are printed.

Set is an unordered collection which means elements can't be accessed through their particular position and no duplicate values are stored in sets.  

You might be interested in
Aurelia is designing a user interface for a new game app. Which of the following should she taken into consideration for the use
serious [3.7K]

Answer:

C

Explanation:

what types of loop will be used.

4 0
3 years ago
How is abstraction used in a GPS system
ipn [44]
The designs on the map of the GPS system Im would think but can you be more specific?
8 0
4 years ago
Read 2 more answers
An administrative assistant types a document, saves, and prints. The assistant is using _____.
9966 [12]
The answer to your question is software. 
3 0
3 years ago
As an experienced networking professional, you are asked to conduct a posture assessment on a local credit union’s network. The
ale4655 [162]

Answer:1987

Explanation:guess

8 0
4 years ago
The small, touch-sensitive area at the base of the keyboard on a notebook computer is known as a ________.
USPshnik [31]
Trackpad.

(Sheep sheep mr sheep meep)
8 0
4 years ago
Read 2 more answers
Other questions:
  • How is the Microsoft Word 2013 window organized?
    11·2 answers
  • "Technician A says that Ohm's law can be used to determine circuit current flow if total circuit resistance and total voltage ar
    14·1 answer
  • An indicator is a comprehensive analysis of critical information
    8·1 answer
  • If(moreDate == true)
    7·1 answer
  • Could someone give an example or tell me what all of these mean? (For internet source citing) Evaluation: • Domain Name: • Autho
    7·1 answer
  • Modify the CountByFives application so that the user enters the value to count by. Start each new line after 10 values have been
    7·1 answer
  • Which of the following is NOT a type of insurance fraud?
    14·2 answers
  • An MP3 player is an example of which of the following types of computer
    5·1 answer
  • What is the first step in finding a solution to a problem?
    9·2 answers
  • At a family reunion, your cousin takes a picture of both of you with her phone, orders a print of it, and mails it to you with a
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!