Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
Question
Book Icon
Chapter 21.7, Problem 21.7.1CP
Program Plan Intro

Program:

//import util package

import java.util.*;

//class definition

public class Example_1

{

//main method

public static void main(String[] args)

  {

/* declare singleton set and add "Chicago" */

Set<String>set = Collections.singleton("Chicago");

//add Dallas into set

set.add("Dallas");

//print set

System.out.println("set is " + set);

  }

}

Blurred answer
Students have asked these similar questions
Set are ordered but not indexed True or false.
Does a set allow you to store duplicate elements?
What will happen if a set has duplicate entries? python     the duplicate copies will not be affected     the duplicate copies will still be printed     none     the duplicate copies will be ignored
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning