I am stuck again with ArrayList
. I already know how to compare two items in Array
but I would like to do the same in list.
So just an example for the comparison.
import java.util.*;
public class ArrayIf {
public static void main(String[] args) {
List numbers = new ArrayList();
numbers.add(5);
numbers.add(9);
if (numbers[1] >= numbers[0]) {
System.out.println ("The second number in the lit is bigger the the first!");
} else System.out.println("The second number in the list is not bigger than the fist!");
}
}
I do know the "if" line is good for the array and not for list AND here is my problem. I looked for but I haven't found how can i get the 2 item from one ArrayList in one Statement working.
I tried
numbers.get(1);
numbers[1]
but non of the worked. Can anybody help how can i get the indexed value out for the if statement?