here is my code:
import java.util.Random;
public class Lehma {
private static final String[] NAMES = new String[]{
"Anu", "Arpa", "Essi", "Heluna", "Hely",
"Hento", "Hilke", "Hilsu", "Hymy", "Matti", "Ilme", "Ilo",
"Jaana", "Jami", "Jatta", "Laku", "Liekki",
"Mainikki", "Mella", "Mimmi", "Naatti",
"Nina", "Nyytti", "Papu", "Pullukka", "Pulu",
"Rima", "Soma", "Sylkki", "Valpu", "Virpi"};
private String name;
private int volumes;
public Lehma() {
int index = new Random().nextInt(NAMES.length);
// Get index item from NAMES list
}
}
How I can get specific index from NAMES string array? I tried to use some get methods, but it didn't work. For example if index is 1, then the return should be "Arpa" because Arpa's index is 1 in NAMES array.