Untitled

mail@pastecode.io avatar
unknown
java
2 years ago
749 B
1
Indexable
Never
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();

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

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