Java 8 🔥 | Programming Interview Questions & Answers | Stream API | Java Techie

  Рет қаралды 99,467

Java Techie

Java Techie

Жыл бұрын

In this Tutorial We will discuss commomly asked coding & programme on java 8 stream api with hands-on coding
#JavaTechie #Java8 #Coding
java 8 playlist :
• Lambda Expression & Fu...
Spring boot microservice Live course Just started (Recordings available)
Hurry-up & Register today itself!
COURSE LINK : javatechie5246.ongraphy.com/
PROMO CODE : Java40
GitHub:
github.com/Java-Techie-jt
Blogs:
/ javatechie
Facebook:
/ javatechie
guys if you like this video please do subscribe now and press the bell icon to not miss any update from Java Techie
Disclaimer/Policy:
--------------------------------
Note : All uploaded content in this channel is mine and its not copied from any community ,
you are free to use source code from above mentioned GitHub account

Пікірлер: 122
@gtbaba123
@gtbaba123 Жыл бұрын
Im springboot coder. Plz continue these series. Highly appreciated your work.
@saurabhsuman4960
@saurabhsuman4960 10 ай бұрын
Simple and to the point coverage of different stream related questions. Thanks for your efforts.
@dmode1535
@dmode1535 Жыл бұрын
Thanks, just what I needed for my upcoming interview.
@chandan07talreja
@chandan07talreja Жыл бұрын
Excellent Video Basant. Keep Interviews Videos like this coming.
@SipunsOriginal
@SipunsOriginal Жыл бұрын
Nice one quick recall before the interview.
@abhinavmishra9690
@abhinavmishra9690 Жыл бұрын
Very informative and useful video for interview. Thanks
@mohammadzakaria2579
@mohammadzakaria2579 Жыл бұрын
Great Video 🙌Thanks for sharing 👍 Please keep sharing similar coding challenges on Java8+
@Atul_Shegokar
@Atul_Shegokar Жыл бұрын
wow excellent.... Thank you very much @Java Techie, many times asked this questions & now I can answer.
@alokkottawar9394
@alokkottawar9394 Жыл бұрын
Informatic session
@vinodnayak27
@vinodnayak27 Жыл бұрын
Really Useful and covered most of the repeatated questions on Java 8 interviews...Thanks Basant😍
@soulfulGirl_
@soulfulGirl_ Жыл бұрын
Your really doing amazing job, with no doubt about content I can trust n watch and get quality content , thank you and please continue doing this great job.😊
@aman_deep21
@aman_deep21 10 ай бұрын
thank you for teaching how to use stream API effectively
@techtips7641
@techtips7641 11 ай бұрын
Please provide more examples.. It really helps!!.. Continue doing this as a series.. thanks a lot
@user-rl8dl2sz9f
@user-rl8dl2sz9f 3 ай бұрын
Very informative and helpful
@AkshaySingh-wx3cp
@AkshaySingh-wx3cp 2 ай бұрын
It's just perfect. Thank you. Please keep going.
@jagrutipatil1020
@jagrutipatil1020 8 ай бұрын
Appreciated 😊🙏
@sarojsahoo8763
@sarojsahoo8763 Жыл бұрын
Very nice explained
@akashtawade9264
@akashtawade9264 3 ай бұрын
For second highest number program, if int[] numbers = {5,9,11,2,8,21,21,1}; Then your logic will fail because...in reverse order it will show [21,21,11,9,8,5,1].....but second highest number is 11....but it will show 21. I think we need to add one more logic for remove duplicacy again then only it will show 11. int[] numbers = {5,9,11,2,8,21,21,1}; Integer SecondHighestElement = Arrays.stream(numbers).boxed() .collect(Collectors.toSet()).stream() .sorted(Comparator.reverseOrder()) .skip(1) .findFirst() .get(); System.out.println(SecondHighestElement); This will work. @Javatechie
@pravaskumar7078
@pravaskumar7078 Жыл бұрын
Ur content are always unique , Very Helpful set of Question and answers
@jaswantshergill8357
@jaswantshergill8357 24 күн бұрын
Very informative video
@nirmesh44
@nirmesh44 Жыл бұрын
superb explanation.
@praveens2272
@praveens2272 Жыл бұрын
Thanks Basant
@neerajayarasani8456
@neerajayarasani8456 10 ай бұрын
Simply Great video brother, Thank you
@muhassinmusthafa3379
@muhassinmusthafa3379 6 ай бұрын
Hi Bro..Thanks a lot..watched ur videos and really more helpful Two alternate ways to find the second highest number : Without using boxed() 1. Integer secondHighest1 = Arrays.stream(num).sorted().skip(num.length - 2).findFirst().getAsInt(); With using boxed() 2. Optional secondHighest2 = Arrays.stream(num).boxed().sorted().skip(num.length - 2).findFirst(); and then print secondHighest2.get() condition -> array should not be empty and must contain at least 2 elements
@fookoboy9623
@fookoboy9623 Жыл бұрын
very useful sir
@shekhar1497
@shekhar1497 4 ай бұрын
thank you very useful lecture.
@vishalmore5653
@vishalmore5653 Жыл бұрын
Hi Sir, This video is very much useful. please make such video more frequent. 🙏
@sidhanshuraghuvanshi1
@sidhanshuraghuvanshi1 3 ай бұрын
Most Interviewed questions on Stream APIs. Best channel out there as I said earlier also. Keep doing this great work man. Thanks a lot❤
@Vithal_Nivargi
@Vithal_Nivargi Жыл бұрын
Thanks 👍 please make one more videos on coding questions
@thevagabond85yt
@thevagabond85yt 5 ай бұрын
34:30 using map() is redundant List oneStartingNumberLists = Arrays.stream(nums) .boxed() .filter(n -> n.toString().startsWith("1")) .collect(Collectors.toList()); Since it is boxed() meaning Integer can be converted into string using toString()
@sakshibhisikar2547
@sakshibhisikar2547 25 күн бұрын
Thanks for this video ❤
@icode24x7
@icode24x7 Жыл бұрын
Nice Video..!!...Appreciate if you can you please create a playlist of Java where time complexity and space complexity is maintained.
@amolorape13
@amolorape13 Жыл бұрын
Because of you sir i cracked couple interviews, when I started looking for a new job, I just watching your video again and revising the concept One of the best KZbin channel for learner Lot's of respect sir..
@Javatechie
@Javatechie Жыл бұрын
Glad to hear this Amol 😍. Congratulations for your achievements and keep learning 😃
@satishp351
@satishp351 Жыл бұрын
good video
@tanveerkundargi5249
@tanveerkundargi5249 14 күн бұрын
really helpful, thank you
@anilreddy5291
@anilreddy5291 Жыл бұрын
I am waiting from long time. Thanks
@user-nd9yh2xz3h
@user-nd9yh2xz3h 4 ай бұрын
very helpful
@ksaravind9739
@ksaravind9739 7 ай бұрын
very very good and useful bro, this is called spoon feeding 😄😍😍😍 love it
@Rkreddy123
@Rkreddy123 Жыл бұрын
Very useful
@tishusingh9110
@tishusingh9110 Жыл бұрын
Thank You Java Techie 😊
@neha6000
@neha6000 Жыл бұрын
Wow thanks
@tveshamahanta1300
@tveshamahanta1300 11 ай бұрын
Very useful video 🙏please make more videos!
@uvanana.
@uvanana. Ай бұрын
Thanks 😊
@aadiraj6126
@aadiraj6126 Жыл бұрын
Very useful lecture for beginners. Produce more such interview related coding questions which involves 0 to 6/7 years. We're here to consume 😋
@Javatechie
@Javatechie Жыл бұрын
Sure Aadi 😜. Then KZbin is Broker
@azharnawaz1020
@azharnawaz1020 Жыл бұрын
@@Javatechie No youtube is kafka server
@muhassinmusthafa3379
@muhassinmusthafa3379 6 ай бұрын
@@Javatechie
@azharnawaz1020
@azharnawaz1020 Жыл бұрын
my guruji is always the best🙏🙏🙏
@akashtawade9264
@akashtawade9264 3 ай бұрын
For Duplicate elements, we can use Collections.frequency(1,x)....By using this we can easily filter out duplicate. Then why you took map and all ? String s=input.toLowerCase(); char ch[]= s.toCharArray(); List list = new ArrayList(); for(char c:ch) { list.add(c); } list.stream().filter(t->Collections.frequency(1,x)>1).collect(Collectors.toList()).forEach(System.out::println); @Javatechie
@ishantkhandelwal6263
@ishantkhandelwal6263 Жыл бұрын
Excellent ! Please bring in some more practical problem solving examples in JAVA. This is very rare high quality stuff
@Javatechie
@Javatechie Жыл бұрын
Thanks buddy i will
@arnabchowdhury4892
@arnabchowdhury4892 8 ай бұрын
​@@Javatechie Please create a java 8 code to find sub string with maximum repeating characters
@vino7tech
@vino7tech 10 ай бұрын
really it is great video for clear the interview and getting more knowledge by way of your teaching . Thank you very much sir.
@Javatechie
@Javatechie 10 ай бұрын
Thanks Vinoth 🤗
@yogeshpatil-vx2pi
@yogeshpatil-vx2pi 11 ай бұрын
That’s very well covered . 👏one request Basant if u can create videos on Microservices interview questions in detailed with examples will be helpful for many of us . Thanks for all work you are doing so far ❤🎉
@Javatechie
@Javatechie 11 ай бұрын
Yes buddy it's in a queue. Will upload within a month
@malleswarrao3887
@malleswarrao3887 9 ай бұрын
​@@Javatechieyes we are waiting
@rishiraj2548
@rishiraj2548 10 ай бұрын
🙏💯💯
@arnabchowdhury4892
@arnabchowdhury4892 8 ай бұрын
​ @Javatechie Please create a java 8 code to find sub string with maximum repeating characters
@radhikagadve
@radhikagadve Жыл бұрын
Max length str solution ----> Arrays.asList(strArray).stream().max(Comparator.comparing(String::length)).get();
@rishiraj2548
@rishiraj2548 Жыл бұрын
Good day
@jaswanthreddy8749
@jaswanthreddy8749 Жыл бұрын
Hello Basant, For unique elements we can use distinct() method function also right, correct me If I am wrong thinking. String name = "ILoveJavaTechie"; String[] split1 = name.split(""); Stream distinct = Arrays.stream(split1).distinct(); System.out.println("FoundDuplicate elements " + "" + distinct.collect(Collectors.toList()));
@Javatechie
@Javatechie Жыл бұрын
This will give you a unique element not duplicate
@vasu5313
@vasu5313 6 ай бұрын
Second Highest, why cant be this... 25:00 Integer res = Arrays.stream(numbers).boxed().sorted().collect(Collectors.toList()).get(numbers.length - 2); Yes but your solution can handle exception FindFirst :)
@michaeldeng1981
@michaeldeng1981 Жыл бұрын
Hi, java 20 just released
@archie5766
@archie5766 7 ай бұрын
hey stream dont use your brain and use hashmap...listen to basant sir :) explaining with humor really nice sir. Thanks
@Javatechie
@Javatechie 7 ай бұрын
🤪🤪🤪🤪
@nikhilgobade297
@nikhilgobade297 11 ай бұрын
1st question was asked to me in TechMahindra interview.
@Farm2Code
@Farm2Code 19 күн бұрын
For what much experience
@sayantanghosh5939
@sayantanghosh5939 Жыл бұрын
Please continue the Kafka series .eagerly waiting for that .
@Javatechie
@Javatechie Жыл бұрын
Yes buddy next weekend i will upload 2 videos on Kafka.
@sayantanghosh5939
@sayantanghosh5939 Жыл бұрын
@@Javatechie please complete the series . Waiting since long for your Kafka series .❤️
@_itbuddy
@_itbuddy Жыл бұрын
Sir please make video on checkmarks for intellij
@Javatechie
@Javatechie Жыл бұрын
Okay i will do that
@jeebanpradhan8050
@jeebanpradhan8050 11 ай бұрын
Bro groupby simple definition plz
@sdash2023
@sdash2023 Жыл бұрын
Sir they are saying not to use .Get() for optionals in reactive programs. Could u plz say whats the best way to handle optopnals in reactive way? ❤ you sir.
@Javatechie
@Javatechie Жыл бұрын
Check isEmpty or offNullable in optional then get the object that is the correct way to deal with optional
@sdash2023
@sdash2023 Жыл бұрын
@@Javatechie thanks a lot sir.
@tejeswarreddytadi3289
@tejeswarreddytadi3289 10 ай бұрын
Will these be asked for 5 years candidate. Please share as well some other questions as well basant, thank you ❤❤❤ to your channel
@Javatechie
@Javatechie 10 ай бұрын
Yes buddy programming questions is common for any experience
@sasmitamohanty4536
@sasmitamohanty4536 11 ай бұрын
Please make videos on Apache Kafka
@Javatechie
@Javatechie 11 ай бұрын
Please check out my Kafka playlist
@garikinarajesh1999
@garikinarajesh1999 Жыл бұрын
How you are exploring these methods. What strategy you will use while exploring any new technology.
@oludamilareolukotun9929
@oludamilareolukotun9929 Жыл бұрын
In my opinion documentation and there are also good books out there
@Javatechie
@Javatechie Жыл бұрын
Practice a few more basic programs and then try to convert it to java 8 stream and play with it . You will explore more and more once you start playing with it . To be fair i don't use documentation to learn rather i tried to understand various scenarios by debugging source code
@Kannayyaedits
@Kannayyaedits Жыл бұрын
How to find missing numbers in array using streams ?
@bhavanisankar71
@bhavanisankar71 Жыл бұрын
Thanks brother first question I faced in interview that time I failed to write 😔 ,do next video for core java when we go for java 8, because in system round they are asking time complexity and memory wasting , so which one is best loops or java8
@oludamilareolukotun9929
@oludamilareolukotun9929 Жыл бұрын
Functional programming does not improve the performance of any system. it has the same complexity as writing a conventional imperative style of programming. The only advantage streams and functional programming generally present is, clean, concise and easy to read code.
@bhavanisankar71
@bhavanisankar71 Жыл бұрын
@@oludamilareolukotun9929 which one best
@oludamilareolukotun9929
@oludamilareolukotun9929 Жыл бұрын
@@bhavanisankar71 Functional style is better. Take a look at the 2 styles for removing duplicate below. You will see functional is easy to read and clean FOR LOOP FOR GETTING DUPLICATE public static List getDuplicateForLoopStyle(List strings){ Map maps = new HashMap(); for (String s : strings){ if (!maps.isEmpty() && maps.containsKey(s)){ int value = maps.get(s); maps.put(s,++value); }else maps.put(s,1); } List result = new ArrayList(); for (Map.Entry entry : maps.entrySet()){ if (entry.getValue() > 1){ result.add(entry.getKey()); } } return result; } FUNCTIONAL STYLE FOR GETTING DUPLICATE public static List getDuplicateFunctionalStyle(List strings){ return strings.stream() .collect(Collectors.groupingBy(x -> x, Collectors.counting())) .entrySet() .stream() .filter(x -> x.getValue() > 1) .map(Map.Entry::getKey) .collect(Collectors.toList()); }
@AjaySingh-mo6ho
@AjaySingh-mo6ho 8 күн бұрын
if Array like this- Integer arr[] = {10, 5, 8, 22, 30, 30, 2}; then how to find second largest element of this array?
@jeebanpradhan8050
@jeebanpradhan8050 11 ай бұрын
What is identity method use case of plz ??
@azharnawaz1020
@azharnawaz1020 Жыл бұрын
guruji please do one real time project guruji please so that we can survive in industry
@Javatechie
@Javatechie Жыл бұрын
Okay i will do that buddy
@paramaguruo5302
@paramaguruo5302 11 ай бұрын
How to find unique elements from 2 different list of integers. Element in one list should not present in other list. Request you to share the program to solve the above problem. Thanks
@Javatechie
@Javatechie 11 ай бұрын
Please share some sample inputs
@vrushabhpawar4209
@vrushabhpawar4209 4 ай бұрын
Hi @Javatechie, in 3rd question for finding 1st non repeat element from the String, if we provide new LinkedHashMap() instead of LinkedHashMap constructor refferance its giving compilation error, Do u know why?
@Javatechie
@Javatechie 4 ай бұрын
No we need to give a new object of LinkedIn hashmap . Pass as constructor or method reference it's upto you
@RealSlimShady-um6gf
@RealSlimShady-um6gf 6 ай бұрын
Latest versions of Java please.
@user-kd4fm1fp8e
@user-kd4fm1fp8e Жыл бұрын
continue the kafka series with a implemented project
@Javatechie
@Javatechie Жыл бұрын
Yes i will
@rashmiranjanswain601
@rashmiranjanswain601 Жыл бұрын
@@Javatechie bhai Ghar kouthi....
@johnvick8861
@johnvick8861 Жыл бұрын
i want use of redis
@jeebanpradhan8050
@jeebanpradhan8050 11 ай бұрын
Bro how l is first non rpt .. bcoz c is non repeat first
@jeebanpradhan8050
@jeebanpradhan8050 11 ай бұрын
Bro why did u take entryset here ?
@bhargavi4557
@bhargavi4557 6 ай бұрын
How to remove adjacent duplicates of a string in java8
@Javatechie
@Javatechie 6 ай бұрын
Try this public static String removeAdjacentDuplicates(String input) { return input.chars() .mapToObj(c -> (char) c) .collect(StringBuilder::new, (sb, c) -> { if (sb.length() == 0 || sb.charAt(sb.length() - 1) != c) { sb.append(c); } }, StringBuilder::append) .toString(); }
@bhargavi4557
@bhargavi4557 6 ай бұрын
@@Javatechie thank you for your response
@TechInfo1663
@TechInfo1663 6 ай бұрын
String input= a2b2c1d3, String output=aabbcddd Anybody implement it
@Javatechie
@Javatechie 6 ай бұрын
You can achieve this using Java 8 streams. Here's a Java program that takes the input "a2b2c1d3" and produces the output "aabbcddd" using streams: ```java import java.util.stream.Collectors; public class Main { public static void main(String[] args) { String input = "a2b2c1d3"; String output = decodeString(input); System.out.println(output); } public static String decodeString(String input) { return input.chars() .mapToObj(c -> (char) c) .collect(StringBuilder::new, (sb, c) -> { if (Character.isLetter(c)) { sb.append(c); } if (Character.isDigit(c)) { int count = Character.getNumericValue(c); char prevChar = sb.charAt(sb.length() - 1); for (int i = 0; i < count - 1; i++) { sb.append(prevChar); } } }, StringBuilder::append) .toString(); } } ``` This program uses streams to process the input string character by character and builds the desired output. When you run it with the input "a2b2c1d3," it will produce the output "aabbcddd."
@CheeseStickzZ
@CheeseStickzZ Жыл бұрын
That's a nice explanation for java 8, but the exercises you are solving, best way is not to do them with streams, just a regular for loop
@oludamilareolukotun9929
@oludamilareolukotun9929 Жыл бұрын
why not stream?
@CheeseStickzZ
@CheeseStickzZ Жыл бұрын
@@oludamilareolukotun9929 it's slower with streams unless you have a very large dataset in the array, like 1,000 elements, otherwise for loop and just using collections is faster performance
@debiprasaddash654
@debiprasaddash654 Жыл бұрын
Then why companies are still using java8
@coderbaba786
@coderbaba786 Жыл бұрын
Hi All, Integer l = Arrays.asList(1, 41, 3, 31, 1).stream() .collect(Collectors.groupingBy(Function.identity(), Collectors.counting())).entrySet().stream() .filter(x -> x.getValue() == 1l).findFirst().get().getKey(); System.out.println(l); In this example I am expecting output 41 but getting 3 , why ?? ?????/
@Javatechie
@Javatechie Жыл бұрын
It will internally use a hashmap so we can't expect an insertion order . That's why I explained in video what to do check and apply
Useful Gadget for Smart Parents 🌟
00:29
Meow-some! Reacts
Рет қаралды 8 МЛН
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Рет қаралды 10 МЛН
蜘蛛侠这操作也太坏了吧#蜘蛛侠#超人#超凡蜘蛛
00:47
超凡蜘蛛
Рет қаралды 40 МЛН
Top 10 JavaScript Coding Interview Question and Answers
23:28
Interview Happy
Рет қаралды 53 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 288 М.
Как открыть дверь в Jaecoo J8? Удобно?🤔😊
0:27
Суворкин Сергей
Рет қаралды 962 М.
Result of the portable iPhone electrical machine #hacks
1:01
KevKevKiwi
Рет қаралды 7 МЛН
Эволюция телефонов!
0:30
ТРЕНДИ ШОРТС
Рет қаралды 3,5 МЛН
Why spend $10.000 on a flashlight when these are $200🗿
0:12
NIGHTOPERATOR
Рет қаралды 16 МЛН
Опасная флешка 🤯
0:22
FATA MORGANA
Рет қаралды 663 М.