How can I print a string value from a list in java?
I have an array with more four strings. I want to print one of the value from the list randomly.
I tried this :
import java.util.Arrays;
import java.util.List;
import java.util.Random;
class Text {
public static void main(String [] args) {
String [] array = {"hello", "world", "coucou"};
List <String> list = Arrays.asList(array);
{
System.out.println("String from the list ="+Random.array);
}
}
}
Can someone help resolve the syntax for System.out.println
?
Thank you.