remove duplicate words in a string | Java by Ponnam Jay |

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I am going to explaining about remove duplicate word in a string this is one string and this string is nothing but Java concept by by J tutorial see here by and by 2 times present inside the string right so what will you do in this scenario we need to remove that two times repeated right that's why we need to remove okay for this one I have one method okay so I'm just commenting this line see observe taking this Str remote to do Dot we need to give what split and here just giving Rejects okay just passing Rejects and this x pattern I'm just passed inside the split method after that when I'm hitting on my keyboard Ctrl 1 and just giving split string array so now observe now I am going to iterating over and split Stringer right so observe string yes split if you are going to printing what will happen whatever iterate over and split array right so those values nothing but Java conceit by by J total will come okay all ship takes J yes absolutely it is uh printed Java concepts by by J tutorial now observe C we need remove this by right it is printed two times but we need printed only one time right we need to remove that one so what will you do previous we already learned right what we need to add asset right we need to add to asset object that means implementation object we need to add right we need to add to the implementation of object this whatever splitted error right so what will you do right you can write set also here set string set here I am going to taking linked headset so that it will take ascending order only if you take linguid asset right so here we need to give what set implementation class object what linked asset right Ctrl shift now observe right this line should be comes to yebo that means after 11th line now observe by using this set object right set dot add and we are passing what this yes the string we are passing that means whatever iterated over on this string split array those words are having this temporary variable called yes right so this temporary variable is consisting these words so we are just adding to the set object this set object now what these words so once you added this set object what will happen duplicate words will remove absolutely will remove okay we'll see now Dot println what we need to print what set Ctrl shift f okay all shift text J Ava concepts by J tutorial but it looks like uh looks not good right see comma comma every every word after comma right this is not good practice see instead of this one I will go for method okay this is Method one I have another method two okay so I'm just going to stream Concepts okay arrays dot stream here what we need to give this string okay Str omodo dot split again here you're using split only so here I am going to pass this rejects only yes okay so after this one again I'm just giving Dot here using distinct method after that one I'm using collect inside this collect method I'm just passing collectors collect as Dot collected dot collectors Dot to list okay but here what I'm going to pass observe it will return what it will written what you are going to expecting okay here I am going to just on my keyboard control one I'm just hitting on my keyboard Ctrl 1 after that one just select this one new Locker variable list of string it will come definitely because of you are just giving the converting to list but we don't want this list so what will you do see observe see I'm just uh Ctrl Z on my keyboard see here collectors Dot joining and here we need to give some string literal space okay so after that one again you can hit Ctrl 1 here see now we got what only one string right so see observe the industry the number of IDs they will use okay but here you are practicing only eclipse or my eclipse or intelligent area there will be not work for you maybe there will be other IDs also will be presented there you have to use their IDs only there is no way okay so you have to practice as and when you have to take other IDs also okay that's why in my channel number of IDs I used okay so I'm going to printing now alt shift x j Ava concepts by J tutorial fantastic okay we just printed without duplicate words see this method 2 and this is Method one this is how we can remove duplicate words inside the string this is J signing off bye bye
Info
Channel: Java concepts by Jay tutorial
Views: 7,263
Rating: undefined out of 5
Keywords: java, java tutorial for beginners, java full course, java interview questions and answers, java code with jay, java programming, collections, collection video, collections in java, collection versus, java 8 streams, java 8 new features, java 8 coding interview questions, java 8 stream api, java 8 tutorial, distinct in java 8, hashset in java, hashset interview questions, joining java 8, joining java stream, java concepts for interview, java for beginners step by step, java se
Id: 7eEemb06GbE
Channel Id: undefined
Length: 9min 57sec (597 seconds)
Published: Sat Oct 15 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.