Untitled

mail@pastecode.io avatar
unknown
java
3 years ago
663 B
1
Indexable
import java.util.Arrays;
import java.util.List;
import java.util.Random;

public class Main {
    public static void main(String[] args) {
        List<String> values = Arrays.asList("a", "b", "c", "d", "e", "g", "a", "s");

        for (int i = 0; i < values.size(); i++) {
            Random random = new Random();
            int randomValue = random.nextInt();

            if(values != null && !values.isEmpty()) {
                if (randomValue % 2 == 0) {
                    values = null;
                }

                String s = values.get(i);
                System.out.println("String value from List is: " + s);
            }
        }
    }
}