I have some problem to compare values from different array list
From this values, I need to compare and find the max n min
Here is my coding:
ArrayList<Integer> S1 = new ArrayList<Integer>(5);
ArrayList<Integer> S2 = new ArrayList<Integer>(5);
ArrayList<Integer> S3 = new ArrayList<Integer>(5);
S1.add(49);S1.add(68);S1.add(91);S1.add(91);S1.add(12);
S2.add(85);S2.add(56);S2.add(62);S2.add(72);S2.add(94);
S3.add(76);S3.add(28);S3.add(52);S3.add(96);S3.add(70);
Example: i want to compare 49,85,76
Firstly, you can add elements in a list easily by
Furthermore, avoid using capitals for variable names, these are reserved for class names.
Now, to answer your question. This can be done using a simple loop:
You’ll end up with two arrays. Each containing the minimum or maximum for a particular index value. I hope this is what you wanted.