Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java random between two strings

String[] s = {"your", "array", "of", "strings"};

Random ran = new Random();
String s_ran = s[ran.nextInt(s.length)];
Comment

java random between two strings

import java.util.Random;
public class RandomSelect {

    public static void main (String [] args) {

         String [] arr = {"A", "B", "C", "D"};
         Random random = new Random();

         // randomly selects an index from the arr
         int select = random.nextInt(arr.length); 

         // prints out the value at the randomly selected index
         System.out.println("Random String selected: " + arr[select]); 
    }
}
Comment

PREVIOUS NEXT
Code Example
Java :: materialbutton remove shadow xml 
Java :: java 8 map foreach 
Java :: json to hashmap java stream 
Java :: split string regex java 
Java :: android add activity parent manifest 
Java :: string to char in java 
Java :: check palindrome in java 
Java :: java dynamic method dispatch 
Java :: Index through 2d array 
Java :: check if sqlexception is duplicate entry java 
Java :: android imageview set image from drawable programmatically 
Java :: get first entry in set java 
Java :: java string to float 
Java :: double.parsedouble in java 
Java :: how to print something in java 
Java :: android remove focus from an element 
Java :: java if or 
Java :: java arraylist deep copy 
Java :: arrays.aslist 
Java :: java call method from another class example 
Java :: android @Parcelize not resolving 
Java :: useColorScheme returning light 
Java :: max and min value in array 
Java :: java currency format 
Java :: fakultät in java 
Java :: skip values in a for loop java 
Java :: reverse in jaav 
Java :: find elements in selenium 
Java :: String remove duplicate method in java 
Java :: java object to int 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =