Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get random element from string array java

String random = (fruits[new Random().nextInt(fruits.length)]);
Comment

get random word from array java

import java.util.Random;

public class Selection
{    
  	public static void main(String[] args)    
    {       
        Random rand = new Random(); 
      	String[] animals = {"Dog", "Cat", "Fish", "Turtle", "Penguin"}; // array of animals
      	System.out.println("Console picked " + animals[rand.nextInt(animals.length)]); // prints the random animal selected from array
    }
}
Comment

get random element from string array java

String[] fruits = {"Apple","Mango","Peach","Banana","Orange","Grapes","Watermelon","Tomato"};
Comment

PREVIOUS NEXT
Code Example
Javascript :: angular new component 
Javascript :: new line in javascript alert 
Javascript :: jquery on element change 
Javascript :: javascript round off 
Javascript :: check object is empty javascript 
Javascript :: change text in html with javascript 
Javascript :: scroll to element in scrollable div 
Javascript :: passportjs serializeuser 
Javascript :: javascript max number 
Javascript :: js encryption 
Javascript :: next js build command 
Javascript :: base64 nodejs image 
Javascript :: check href javascript 
Javascript :: javascript replace with UpperCase 
Javascript :: json object check if key exists java 
Javascript :: angular go to external url with blank target 
Javascript :: how to counts date from moment js 
Javascript :: delete all the fields on the form whit jquery 
Javascript :: react native text style example 
Javascript :: merge sort algorithm in javascript 
Javascript :: check / unchecked a checkbox with jQuery 
Javascript :: resize array javascript 
Javascript :: first N elements of an array javascript 
Javascript :: nextjs getserversideprops 
Javascript :: hypot in javascript 
Javascript :: flatten 2d array javascript 
Javascript :: window change detect 
Javascript :: catch javascript 
Javascript :: javascript flatten array of arrays 
Javascript :: sequelize update sql 
ADD CONTENT
Topic
Content
Source link
Name
5+4 =