Java 8 Q&A | 🔥 Asked in Myntra | Find Nth Highest Salary Using Java Streams API | JavaTechie

  Рет қаралды 53,223

Java Techie

Java Techie

Күн бұрын

Пікірлер: 103
@sreetmi1918
@sreetmi1918 Жыл бұрын
this is really good video for those who are lagging in doing programming with corejava.... if any one practice this and learn doing on their own..they ll start become stronger and stronger intheir coding skillls... thanks for the good work..
@purnasahu8766
@purnasahu8766 Жыл бұрын
Excellent, plz bring such new types of java coding questions in your upcoming videos...
@sagarjaiswal9451
@sagarjaiswal9451 Жыл бұрын
Optional secondHighestEmployee = employees.stream() .collect(Collectors.groupingBy(Employee::getSalary, TreeMap::new, toList())) .entrySet() .stream() .skip(n-1)// .map(Map.Entry::getValue) .findFirst(); System.out.println(secondHighestEmployee);
@Krishnadevaraya1
@Krishnadevaraya1 7 ай бұрын
Employees is a list or map
@tanson86
@tanson86 Жыл бұрын
Nice incremental way of teaching streams in general.
@charliegamboa9567
@charliegamboa9567 Жыл бұрын
What a useful content and example. Thanks for sharing
@vaidehikannan4337
@vaidehikannan4337 26 күн бұрын
Excellent work, thank you sir
@kshitijbansal3672
@kshitijbansal3672 Жыл бұрын
Sir, I cant thank you more, today I had 2nd technical round with TechM, the interviewer asked the same question, that how you will group male and female on the basis of dept. but you are getting the Dept. name as a method argument. I randomly watched this video 3-4 days back and today when interviewer asked this question, I could only think about this video and provided him the solution in a minute.
@Javatechie
@Javatechie Жыл бұрын
Glad to hear this buddy 🥰🥰. Keep learning 😃
@rushikeshgodase4150
@rushikeshgodase4150 Жыл бұрын
Your experience. How much package they offered??
@sandeep_begudem
@sandeep_begudem 9 ай бұрын
for me remembering the entire syntax is tough. I don't know how would someone memorize the entire syntax and get the expected result LOL😇 Thank you Basant for creating amazing content!
@sajid.farooqi8074
@sajid.farooqi8074 Жыл бұрын
Nice way of delivering such complicated looking problem.
@Suryanarayan094
@Suryanarayan094 Жыл бұрын
We want more this kind of videos.
@gangadharreddy4606
@gangadharreddy4606 18 күн бұрын
great work.
@gopisambasivarao5282
@gopisambasivarao5282 Жыл бұрын
Thanks Basanth.Nice Video. God bless you.
@abhishekgowlikar
@abhishekgowlikar Жыл бұрын
Amazing videos for java techies.
@sajid.farooqi8074
@sajid.farooqi8074 Жыл бұрын
Hi please bring a complete tutorial on multi threading programing. As of no complete vedio tutorial i have found on KZbin.
@Javatechie
@Javatechie Жыл бұрын
Okay buddy i will
@hadouken99
@hadouken99 Жыл бұрын
Thanks for good content. Hope you keep sharing on((:
@jairam884
@jairam884 Ай бұрын
Nice
@krishnapriya-b7s
@krishnapriya-b7s Ай бұрын
Thank you. Could you please explain how to write program for placing n queen in n*n board?
@beetc305shivsundarbankar9
@beetc305shivsundarbankar9 Жыл бұрын
In output we got the map has key salary and value name, but if I want same map in which key is name and salary is value is it possible?
@vino7tech
@vino7tech Жыл бұрын
Thank Your very Much sir. Many programmers are learn more knowledge by yours videos.
@DurgaShiva7574
@DurgaShiva7574 Жыл бұрын
superb content
@sumitsehgal8034
@sumitsehgal8034 Жыл бұрын
Good one brother
@user-0987-a
@user-0987-a Жыл бұрын
Big thanks from Africa
@personalsivakrishnareddy9403
@personalsivakrishnareddy9403 2 ай бұрын
Hello Sir, Pls explain this interview question int[] numbers = {1, 5, 7, -1, 5} out put is (1,5),(7,-1),(5,1) and combination is 3
@Javatechie
@Javatechie 2 ай бұрын
Here combination is 6 right? You need to figure out pair whose sum is given input
@sudharsansathiamoorthy1075
@sudharsansathiamoorthy1075 Жыл бұрын
Excellent tutorial Bro!! Please keep post solving new problems!!
@rabisankarpodder7839
@rabisankarpodder7839 Жыл бұрын
I have made it by the following way Employee nthHighestEmployee = employees.stream() .sorted(Comparator.comparingDouble(Employee::getSalary).reversed()).skip(n - 1).findFirst() .orElse(null);
@Javatechie
@Javatechie Жыл бұрын
If multiple employees have the same value will it work ?
@rabisankarpodder7839
@rabisankarpodder7839 Жыл бұрын
@@Javatechie Yes it will take the previous value for 3rd highest salary. e.g . List employees = new ArrayList(); employees.add(new Employee(101, "John", 5000)); employees.add(new Employee(102, "Alice", 8000)); employees.add(new Employee(103, "Bob", 3000)); employees.add(new Employee(104, "Mary", 6000)); employees.add(new Employee(105, "Tom", 2000)); employees.add(new Employee(106, "Jane", 7000)); employees.add(new Employee(108, "Rabi", 6000)); employees.add(new Employee(107, "Mike", 4000)); Output:- Employee [empId=104, empName=Mary, salary=6000]
@ManojKumar-te5by
@ManojKumar-te5by Жыл бұрын
Can you make an real example of Optional where use some frequent and important methods like OrElseGet() etc
@bnayak8039
@bnayak8039 10 ай бұрын
Hey thank you so much you deserve lasts of appreciation, but I expected not enough from you
@suryaambati4880
@suryaambati4880 Жыл бұрын
Hi ,I have list of employee objects I just want sort my employee list based on name in ascending order age in descending order ,salary in ascending order at a time How we make this combine sort ?
@Javatechie
@Javatechie Жыл бұрын
You need to customize your comparator. There is no direct support given by java 8
@Aman-Thakor
@Aman-Thakor Жыл бұрын
If I'm passing num value gt than size of sorted list, it will fail at get(index). What we can do in that case on streams?
@Javatechie
@Javatechie Жыл бұрын
Definitely it will fail, so you need to validate that num
@souvikc37
@souvikc37 Жыл бұрын
Awesome 👍
@abasahebbhingardeve5464
@abasahebbhingardeve5464 Жыл бұрын
Kindly make a video on fetching Arrey Index of top 4 records from millions of record in a database.
@srinath710
@srinath710 Жыл бұрын
Good one ❤
@siddharthagrawal4280
@siddharthagrawal4280 Жыл бұрын
I have upcoming interview 2nd round on Friday. I know backend spring boot but am not aware of java 8 and all crucial features and usecases of it, i am told it will be asked for sure. Can you please suggest me few sources to understand everything about java 8 from scratch?? Or best make a small playlist if possible. Humble request! Could be Life changing for me!
@Javatechie
@Javatechie Жыл бұрын
It's already there please have a look kzbin.info/aero/PLVz2XdJiJQxzrdrpglCv_nWIO5CDIqOVj
@siddharthagrawal4280
@siddharthagrawal4280 Жыл бұрын
Completed the playlist! It's pure Gem. Thanks man.
@raviravi-gg5ck
@raviravi-gg5ck 11 ай бұрын
​@@siddharthagrawal4280 u got selected ?
@siddharthagrawal4280
@siddharthagrawal4280 11 ай бұрын
@@raviravi-gg5ck yes bro! This is great source for getting industry ready
@munkhbayar3940
@munkhbayar3940 Ай бұрын
The solution based on sorting is not optimal. min/max heaps should be used. can the Java Stream API provide the optimal solution based on the min/max heaps?
@sdash2023
@sdash2023 Жыл бұрын
Sir I LRU and LFU cache using LinkedHashMap please. I failed epam interview because of LFU cache.
@Javatechie
@Javatechie Жыл бұрын
Okay i will
@sdash2023
@sdash2023 Жыл бұрын
@@Javatechie thank you Sir.
@chiranjib2patra
@chiranjib2patra 8 ай бұрын
Thats a very good approach to teaching Basanth✌️ Liked it👍 Also would like to suggest if you could add a bigger display then the whole code we might get to see the single screen.
@YogeshGhode-j5j
@YogeshGhode-j5j 11 ай бұрын
Hi Sir why you have used "Collections.reverseOrder(Map.Entry.comparingByKey())" insted of "Comparator.comparing(Map.Entry.comparingByKey()).reversed()"
@naincysharma5522
@naincysharma5522 Жыл бұрын
Can you please help on a interview question where they asked to create a person class that has some fields like id, name, address, age etc and there can be 100+ such field in person class. We need to write a program to sort the person data using some dynamic criteria, like sample criteria can be Id only Id+ name Name onky Age onky Id+name+age And so on Can you help me on this.. She suggested to use reflection api getdeclaredfield method and getproperty to solve yhis...which i cud not relate to
@Javatechie
@Javatechie Жыл бұрын
Sure i will check this buddy. Quite interesting
@naincysharma5522
@naincysharma5522 Жыл бұрын
@@Javatechie thank you so much!!
@pedurujagadish5048
@pedurujagadish5048 Жыл бұрын
Bro realtime project implement action series chey bro
@punyabikash3624
@punyabikash3624 8 ай бұрын
Hello Sir, thank for this 👍👌 i have one question face by Cognizant that there is an array of integers he wanted out put as - { { 1,1,1,1},{2,1,1},{2,2},{3,1} } all possible combination of numbers whose sum is 4 if 4 is passed from console, if i pass 5 then all possible sum and so on could you help to make a video of it...plz
@Javatechie
@Javatechie 8 ай бұрын
It's very simple you can try the approach below import java.util.stream.IntStream; public class NumberCombinationSum { public static void main(String[] args) { int targetSum = 10; findCombinations(targetSum); } public static void findCombinations(int targetSum) { IntStream.rangeClosed(1, targetSum / 2) .forEach(num1 -> { int num2 = targetSum - num1; System.out.println(num1 + " + " + num2 + " = " + targetSum); }); } }
@punyabikash3624
@punyabikash3624 8 ай бұрын
Thanks a lot for your Response :) :) this is not what he was expecting for example - i will pass 4 from console then output should be - { { 1,1,1,1},{2,1,1},{2,2},{3,1} } For example i will pass 5 then output should be - { { 1,1,1,1,1},{2,2,1},{3,2},{4,1} } For example i will pass 6 then output should be - { { 1,1,1,1,1,1},{2,2,2},{3,3},{4,2},{5,1} }
@Javatechie
@Javatechie 8 ай бұрын
Ohh okay got it any combination. Will try and update you
@naincysharma5522
@naincysharma5522 Жыл бұрын
Even if you cant...no worries..thanks for your efforts in making these videos that are of so much help
@Anilkumar-reddy
@Anilkumar-reddy Жыл бұрын
Good video bro. Please make a more videos on java8 interview questions
@Javatechie
@Javatechie Жыл бұрын
Already uploaded buddy please search with keyword interview
@krishnan6201
@krishnan6201 Жыл бұрын
can you please make video on functional interface with recursive?
@Javatechie
@Javatechie Жыл бұрын
Recursive function class?
@krishnan6201
@krishnan6201 Жыл бұрын
@@Javatechie No Recursive with lambda implementation any logic like factorial given number consider as example.
@yatendra__singh
@yatendra__singh Жыл бұрын
After watching these kind of videos from you ...i am just thinking how some one like you❤ got this much of depth knowledge in java ... could you please explain me in one word??
@PKKCAD
@PKKCAD Жыл бұрын
May be he tried multiple times in offline.
@Javatechie
@Javatechie Жыл бұрын
I think the permanent hunger of learning helps everyone , thank you so much for your valuable words.
@Javatechie
@Javatechie Жыл бұрын
Of course Kk , i have tried it and understand the purpose of each line before preparing the video .
@sajid.farooqi8074
@sajid.farooqi8074 Жыл бұрын
@@PKKCAD nothing is without practicing
@priyankapatil6783
@priyankapatil6783 4 ай бұрын
can you please try this find the largest word in a string in java
@bhavanisankar71
@bhavanisankar71 Жыл бұрын
Sir please tell me how extract Text, table, images data from pdf using java. I am able to extracting text but remaining things how to get please tell me any solution
@immortalhuman7085
@immortalhuman7085 Жыл бұрын
Can you make video on how to switch from service based company to product based company?
@RiskyRishy
@RiskyRishy Жыл бұрын
great
@bhargavi4557
@bhargavi4557 Жыл бұрын
I was asked in a interview How to remove adjacent duplicates of a string in java8
@Javatechie
@Javatechie Жыл бұрын
Try below approach 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(); }
@sourabh2635
@sourabh2635 7 ай бұрын
Optionalsecodhighest=list.stream().sorted(Comparator.comparing(Employee::getSalary)).skip(3).findFirst(); sysout(secondhghest) -- is this correct?
@Thd369
@Thd369 Жыл бұрын
Thank you
@mehedihassan5184
@mehedihassan5184 Жыл бұрын
Thanks
@pedurujagadish5048
@pedurujagadish5048 Жыл бұрын
And also debugging process in realtime project chey bro series
@Javatechie
@Javatechie Жыл бұрын
Please check this link buddy kzbin.info/www/bejne/gaDRYnd9rMensMk
@muthulakshmisk5650
@muthulakshmisk5650 Жыл бұрын
Hi bro.. ur videos are more clear. Are you working in software company?
@Javatechie
@Javatechie Жыл бұрын
Thank you buddy Yes i am a working employee in it
@PrinceJeniFX
@PrinceJeniFX 9 ай бұрын
How many years experience interview was this?
@Javatechie
@Javatechie 9 ай бұрын
4+, but it can ask a fresher or even can ask to n+ experience
@shivAgar2020
@shivAgar2020 Жыл бұрын
Experience ??
@devkratos711
@devkratos711 Жыл бұрын
👍
@rishiraj2548
@rishiraj2548 Жыл бұрын
🙏👍
@saurabhsuman4960
@saurabhsuman4960 Жыл бұрын
Hello Sir, Nice content and thanks for detailed explanation. I have one question for sorting applied after grouping, Since the map key is Integer than shouldn't this apply sorting by default by using sort() method without passing Comparator implementation? I tried this but it failed and hence I thought to ask here kzbin.info/www/bejne/m3Onf2NqgdF4hck
@Javatechie
@Javatechie Жыл бұрын
Not getting you buddy could you please elaborate it little bit
@saurabhsuman4960
@saurabhsuman4960 Жыл бұрын
@@Javatechie Apologies for confusion. I thought entry set can be sorted by using just sorted() method. It is clear that we need to pass Comparator for sorting of entry set.
@Javatechie
@Javatechie Жыл бұрын
Np
@66thakur99
@66thakur99 Жыл бұрын
private static Entry getnthHighestSalaryEmployeeName(Map mappedWithSalary, Integer n) { return mappedWithSalary.entrySet().stream() .sorted(Collections.reverseOrder(Map.Entry.comparingByKey())) .skip(n - 1) .findFirst() .orElse(null); }
@Javatechie
@Javatechie Жыл бұрын
Execute this with different input there is a loop whole
@sarojsahoo8763
@sarojsahoo8763 Жыл бұрын
Map dataMap = new HashMap(); dataMap.put("Bharat",10000); dataMap.put("Ram",1200); dataMap.put("Laxman",1600); dataMap.put("Ravan",4500); dataMap.put("Lav",5230); Map.Entry nthHighest = dataMap.entrySet().stream() .sorted(Map.Entry.comparingByValue(Comparator.reverseOrder())) .skip(2) .findFirst() .get(); System.out.println(nthHighest); //Can be done this way also
@nehasharma-lg3we
@nehasharma-lg3we Жыл бұрын
It will not consider the case when two people have same salary I guess
@Javatechie
@Javatechie Жыл бұрын
Saroj yes if there will be more than 1 employee having the same salary it won't work
@kshitijbansal3672
@kshitijbansal3672 Жыл бұрын
Sir, I cant thank you more, today I had 2nd technical round with TechM, the interviewer asked the same question, that how you will group male and female on the basis of dept. but you are getting the Dept. name as a method argument. I randomly watched this video 3-4 days back and today when interviewer asked this question, I could only think about this video and provided him the solution in a minute.
@priyankaakhade5164
@priyankaakhade5164 Жыл бұрын
Hi Kshitij, What would be the data format to group male and female on the basis of dept?
@Sumeshkumarback
@Sumeshkumarback 4 ай бұрын
You have been placed?
I'VE MADE A CUTE FLYING LOLLIPOP FOR MY KID #SHORTS
0:48
A Plus School
Рет қаралды 20 МЛН
БАБУШКА ШАРИТ #shorts
0:16
Паша Осадчий
Рет қаралды 4,1 МЛН
Java 8 Streams | map () & flatMap() Example | JavaTechie
15:37
Java Techie
Рет қаралды 223 М.
SOLID Design Principles in java with Example | JavaTechie
34:44
Java Techie
Рет қаралды 201 М.
Java 8 Streams | Optional Usage and Best Practices | JavaTechie
22:22
I'VE MADE A CUTE FLYING LOLLIPOP FOR MY KID #SHORTS
0:48
A Plus School
Рет қаралды 20 МЛН