Java Program to find common elements from two arrays
Вставка
- Опубліковано 2 жов 2024
- This video contains java programming questions along with solution.
One of the best book for Interview Questions
Top 1000 Java Interview Questions & Answers: Includes Spring, Hibernate, Microservices, GIT, Maven, JSP, AWS, Cloud Computing @ amzn.to/32zFihe
Best Laptops : amzn.to/33rBT4A
Best Software's : amzn.to/3h9TTbw
📌 Do Subscribe for all Updates.
Telegram : Drunken Engineer
t.me/DrunkenEn...
You can follow us on Facebook :
/ drunkenengineer8
Feel free share your Interview Experience with us @ funnytechiees@gmail.com
#javacodingquestions #interviewquestionsandanswers #interviewpreparation
java coding questions,
java coding interview questions,
java programming interview questions,
java interview questions for experienced
We can get both union and intersection with two for loops:
String arr1[]= {"java","interview","questions","for","experienced"};
String arr2[]= {"java","fresher","interview","questions"};
Set set=new HashSet();
for(int i=0;i
Why did stop uploading new videos since one year. Please upload other product based companies java interview
Immediate question what is the time complexity from interviewer 😮
String[] s1 = {"java","python","aws"};
String[] s2 = {"java","perl","aws"};
Arrays.stream(s2)
.filter(Arrays.asList(s1)::contains)
.forEach(str -> System.out.print(str + " "));
output: java aws
String[] s1 = {"java","python","aws"};
String[] s2 = {"java","perl","aws"};
for(String s:Arrays.asList(s1)) {
if(Arrays.asList(s2).contains(s)) {
System.out.println(s);
}
}
using java 8 one way to find the common String
String[] a = {"java","python","hibernate", "spring"};
String[] b= {"core","java","spring","microservices"};
List a1 = Arrays.asList(a);
List b1 = Arrays.asList(b);
List collect = a1.stream().filter(b1::contains).collect(Collectors.toList());
System.out.println(collect);
Sir, it is been a long time we have been waiting for the video. Please help us in getting the job
👍
Bhai new interview video waiting. It’s help to learn
Looking for your interviews...
No video since last 7 months
Alternate way using java 8:
String[] fruit1 = {"apple", "mango", "banana", "papaya", "apple", "mango", "banana"};
String[] fruit2 = {"apple", "grape", "banana", "orange"};
Stream f1 = Arrays.stream(fruit1);
Stream f2 = Arrays.stream(fruit2);
Map groupString = list.stream().collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
groupString .entrySet().stream().filter(e -> e.getValue()>1).map(e -> e.getKey()).forEach(System.out::println);