Question
Book Icon
Chapter 21.2, Problem 21.2.8CP
Program Plan Intro

Program:

// Java code for adding elements in Set

//import util package

import java.util.*;

//class definition

public class Set_Example {

// main method

public static void main(String[] args) {

// create a new empty LinkedHashSet

Set<String> set = new LinkedHashSet<>();

// add element ABC into the set

set.add("ABC");

// add element and into the set

set.add("ABD");

// print elements present in the set

System.out.println(set);

}

}

Blurred answer
Students have asked these similar questions
show all the work
answer question 3
Show the work
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
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning