How to find common elements between two arraylist using java8
As we know java 8 is faster than java in performance as well as there are lot of good reasons which always prefer us to use java 8 compared to java 7.Here I am sharing with you the simple java hacks using java8 compared to older java versions which we can use in our daily projects. 1)How to find common elements between two arraylist in java? Suppose I have one list list1:{1,2,3} and other list ie list2:{2,3,4} as we all know which is the common element in the two list ie {2,3} Input lists ---------------- list1;{1,2,3} list2:{2,3,4} Output --------------- o/p list :{2,3} Ans: public class CommonElement{ public static void main(String []args){ List<Integer> list1=new ArrayList<>(); list1.add(1); list1.add(2); list1.add(3); List<Integer> list2=new ArrayList<>(); ...