The pursuit of the highest performance, spent several hours yesterday to do improvement, found it very simple, you to try it on
CodePudding user response:
It is good to poor with collection occurring simultaneouslyFor example
public class Sample {
Public static void main (String [] args) {
Int [] num1={1, 2, 3, 8, 9, 5};
Int [] num2={2, 3, 4, 5, 6, 7};
ListL1=new ArrayList<> (a);
ListL2=new ArrayList<> (a);
For (int n: num1)
L1. Add (n);
For (int n: num2)
L2. Add (n);
L1. RetainAll (l2);//the intersection of two sets of
System. The out. Println (l1);
}
}
CodePudding user response:
Add two arrays have, in accordance with the smallest to complete