Random element from a list java
import java.util.ArrayList; import java.util.List; import java.util.Random; class TestJava { public static void main(String[] args) { List subjects = new ArrayList(); subjects.add(“Java”); subjects.add(“C”); subjects.add(“C++”); subjects.add(“MySQL”); subjects.add(“Oracle”); Random randomizer = new Random(); String randomListElement = subjects.get(randomizer.nextInt(subjects.size())); System.out.println(“Random List Element: ” +randomListElement); } } Output: Random List Element: MySQL