EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Add and display the elements(4 elements) using HashSet, check if an element exists there in a hashset,remove the element..

 

Find the smallest and largest element(number) using treeset

 

class Display

{

public static void main(String args[])

{

HashSet<String> a=new HashSet<String>();

 

a.add(“apple”);

a.add(“mango”);

a.add(“banana”);

a.add(“apple”); //apple mango banana

 

System.out.println(“mango is there..”+a.contains(“mango”));

 

a.remove(“mango”);

System.out.println(a);

}

}

—————————————————–

import java.util.*;

 

class ASC

{

public static void main(String args[])

{

TreeSet<Integer> a=new TreeSet<Integer>();

 

a.add(50);

a.add(20);

a.add(50);

a.add(40); //20 40 50

 

System.out.println(“Smallest=”+a.first());

 

System.out.println(“Largest=”+a.last());

 

 

}

}

Display elements by hashset in java

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer