 good morning guys welcome back to our channel so today in this video I'll be sharing you one of the question that I have recently faced and I was unable to answer that question so this was the input that was being to me and the output was to discrete this in this format like inside this brackets and this delimiter so whenever whenever when I was asked this question I was I felt it was very easy and what I did so I started coding directly now I thought of using string builder and I can easily code to be honest how we can easily achieve this using input array using string builder so I thought let us create one string builder as be equal to no string builder so let us create string builder and using so when a string builder and one furlough I thought of doing this using append so when I coded this the interviewer asked me to stop and like he don't want the output like he don't want me to use string builder class he wanted me to do it using some other class which is there which has been introduced in Java to be honest at that point I was not aware of that class so later on I googled it and I learned it that there is one class that called introduced in Java 8 that is string joiner so if you see there are two constructors here one will take the delimiter one will take three parameters delimiter prefix and suffix so I will take the second one so firstly what what is our delimiter hi-file so now prefix suffix now using one for enhance furlough we can achieve our goal so input array I will be using a for each also string input a rr call and you don't go with the naming condition just because I have defined input here already so I was using something so joiner dot add of all the input are that's it now if at all now if I print this joiner joiner class sysout okay joiner dot to string so let me run this program now and see the output so we got the desired output so this was the expectation from the interviewer like to use string joiner class that is introduced in Java 8 so I thought of using string builder and I was unable to answer actually I was not aware of this so apart from this if at all this question can be asked in this way as well so suppose you have been given one array like let me create one arrays or as least are similar thing same thing let me take hello how are you let me type bitter comma so let me create one list took a list got great list of string so using stream also we can achieve we can apply this joiner class let me see how input input list can say so let me okay you tell so we got this input list so using like we can directly stream on this apply stream operation stream dot directly you collect using collectors collectors dot joining of give the delimiter that's it you can directly get this so this will return any string output so break this line and now let us print this output so let me run this so yeah we got the desired output using hyphen with whatever delimiter but that we give you so we can apply the same thing on the input string input as well and using streams we can apply this using collectors dot joining method we can apply the delimiter and we can get the desired output here so thought of sharing with you all guys thought like when I was not aware or maybe there are few guys who are not aware of this class and it might help to those people or if at all they encounter anywhere such scenario and thank you for watching that's it in this video