13. Java Singleton and Immutable Class Explained with Examples | Java Classes in Depth - Part4

preview_player
Показать описание
➡️ Notes Link: Shared in the Member Community Post (If you are Member of this channel, then pls check the Member community post, i have shared the Notes link there)

➡️ Join this channel to get access to member only perks:

Topics which i have covered in this video:

- Singleton Class
- Eager Initialisation
- Lazy Initialisation
- Synchronised Method
- Double Checked Locking
- Bill Pugh Singleton Solution
- Enum Singleton Solution
- Immutable Class
- Wrapper Class

Chapters:
00:00 - Introduction
00:19 - Singleton Class Definition
02:00 - Eager Initialisation (Singleton)
05:01 - Lazy Initialisation (Singleton)
06:28 - Synchronised Method (Singleton)
08:37 - Double-Checked Locking (Singleton)
16:14 - Bill Pugh (Singleton) Solution
18:35 - Enum(Singleton) Solution
19:52 - Immutable Class
27:21 - Wrapper Class

#java #softwareengineer #inteview
Рекомендации по теме
Комментарии
Автор

Hi Shrayansh, I have been following this Java series from sometime and just wanted to shout out that you have made this learning enjoyable for us. You really teach things from first principle which is just amazing. Keep up the amazing work.

PremSingh-qxek
Автор

By declaring the inner class as static, it's only loaded into memory when it's referenced for the first time. This means that the instance of the Singleton class is created lazily, i.e., only when the getInstance() method is called for the first time. This helps improve performance by avoiding unnecessary early instantiation.

umairalvi
Автор

14:13 because of the happens before guarantees, it will never happen that the second thread will find the object as null inside the synchronization block. Using volatile seems like an overhead as it will cause latency issues throughout the lifecycle of this application.

rahulsangvikar
Автор

Great Video Shrayansh. Just a small question for the Immutable class section. Should we not do a deep copy in the parameterized constructor as well, just like the getter method for collection classes? Because the original object can be modified if someone makes an addition to the petNameList right?

digitalanalytics
Автор

In Bill Pugh Solution, why we created instance_object as final, and also why aren't we using final keyword with other solutions (for instance ). Can you please explain this, it will be a great help.

A_CupOf_Life
Автор

We can create a new arraylist in the constructor and make a copy of the list and that would solve the problem too ., right?

TechSavyHere
Автор

Hello..thank @Shryansh for this educative and awesome content.. I have a question, please anyone who understands the question and has a clue to the answer can still please help me.
The Question is:
According to the Singleton session were different types of Singleton class was touched. If the Synchronized Singleton class is solving the two thread issue, which Lazy initialization is facing...Then how Eager initialization managing the two thread issue Synchronize Singleton class is solving.

chukwukennedy
Автор

can you please cover Multithreading and Concurrency in-depth, Sir?would be big help

codelogics
Автор

Hello Shrayansh, Thank you so much for such great explanation.
One doubt - in lazy initialization as we have already made the variable to static then how come multiple threads working parallelly create 2 copy of it.. As it is class variable now. I mean to ask why making the constructor private & making the variable to static only does not help??

amiyamishra
Автор

Hi i started with java palylist but there is no proper sequence followed actually, threads are at last part, but you used the concept here, did i miss something or you made threads earlier?

siddharth
Автор

In the constructor we should do new List<>(petNamelist);

umairalvi
Автор

you mentioned we have discussed about string pool, in which video? i couldn't find

afzalkhan
Автор

hi Sj, can you please cover a session that explain Strings in details?

afzalkhan
Автор

Great Video, Shreyansh ! If I want to join this channel wit Membership perks, will this be recurring payment every month??

divyanshumaheshwari
Автор

well 2:38 how can you create object just inside class, it should atleast be inside any method know? like main or something

indianhits
Автор

I went through the community posts but couldnt find the notes of any class. Please tell where to find the notes

umairalvi
Автор

If you are making a playlist, make them visible to each users otherwise there is no need ir you can sell your courses. I started following your channel and subscribed it too but here scene is different. One video available and the next is not( available for members with higher price) .. leaving it . Thanks

dassneha
Автор

with CompleteableFuture and async calls and Listenable<Future> ..with such topics

codelogics
Автор

in immutable class it should be
this, petNameList = ArrayList<>(petNameList));

please correct if I am wrong

shivamyadav
Автор

bhaiya, please increase the frequency of the vedio .. upto when we start springboot??
..kindly respond

roshanjha