UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

How are emptySet(), singleton & unmodifiable methods in Java Collections useful?

Asked by Last Modified  

1 Answer

Learn Java

Follow 0
Answer

Please enter your answer

Java Expertise

"emptySet()" is used to return empty and unmodifiable set. Instead of deals with returning null it will return empty. we can avoid nullpointerexception. Also returned empty set is unmodifiable we will get UnsupportedOperationException if we try to modify. All unmodifiable methods like Collections.unmodifiableSet,Collections.unmodifiableList,Collections.unmodifiableMap...
read more
"emptySet()" is used to return empty and unmodifiable set. Instead of deals with returning null it will return empty. we can avoid nullpointerexception. Also returned empty set is unmodifiable we will get UnsupportedOperationException if we try to modify. All unmodifiable methods like Collections.unmodifiableSet,Collections.unmodifiableList,Collections.unmodifiableMap will return unmodifiable list,set,map and whenever we will get the scenario that the client or any third party vendor should not allow to modify list or set or map once it get generated we can go for unmodifiable methods.It allows us to share a list, set or map with another objects without giving them the possibility to modify them, while we can manipulate them as required. "Collections.singleton" this method is to remove an element from Collections like List and Set at once. Let as take Example, I have list {1,2,5,2,4,9,2} if i try to remove '2' without using singleton i will get result as, Remove 2 without using singleton:{1,5,2,4,9,2} Remove 2 with using singleton:{1,5,4,9} it will remove all '2' at once. read less
Comments

Related Questions

What equipment do you need to teach online Java classes?
Team Viewer is the best tool for the same.
Imran
0 0
5
How many classes will it take to learn core Java?
25-35 . depends on the student's previous knowledge on any programming languages
Gene
Why string objects are immutable?
We cannot change the String object because String is immutable. Vice-versa is not the same. String is immutable because of the security. Sting is storing the data in String Pool which can be used by multiple...
Sujatha
What is a singleton class and when do you use it?
Singleton class have a private constructor. while we can't create an object from outside of class, we can create an object only once.
Prakash
Who can provide good Java training with real-time but not institute?
I provide industry specific training to students. If interested check my profile. I used to provide training in Big Data, Java, Scala and Spark too.
Sridevi
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Understanding concept of Inheritance in Java
Inheritance: Acquiring a properties and methods from Parent class to Child class. For example, In some cases we can hear from any one of your relative or your friends will say like that "You are bahaving...

Most Important Java Interview Topics
Dear All, I am here to help on java interview preparation for fresher and experienced people, please get in touch with me for further details. All interview preparation will be with unique teaching style...

Features Of Java
There is given many features of Java. They are also known as java buzzwords. The Java Features given below are simple and easy to understand. Simple. Object-Oriented. Portable. Platform independent. Secured. Robust. Architecture...
V

Java Achieve (JAR)
Java Archieve is a binary form to bundle a Java library which equivalent to zip file. It contains .class files, .properties, .jpeg, OR any supporting files to execute this library. For Example- junit.jar,...

Class and Objects in Java
Class is a template or a blueprint which is used to describe an object. On other hand Object is a reference of a class which follows all the stuff written inside the class. How about taking the whole tour in the following video

Recommended Articles

Before we start on the importance of learning JavaScript, let’s start with a short introduction on the topic. JavaScript is the most popular programming language in the world, precisely it is the language - for Computers, the Web, Servers, Smart Phone, Laptops, Mobiles, Tablets and more. And if you are a beginner or planning...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more