Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

select word from array

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

PREVIOUS NEXT
Code Example
Java :: how to remove spaces from an array in java 
Java :: lombok gradle dependency spring boot 
Java :: how to crate an array of integers in java 
Java :: java stream sum integers 
Java :: Java JPanel set background color 
Java :: how to open an activity from a fragment 
Java :: thymeleaf string not equal 
Java :: print star pattern in java 
Java :: has integer java 
Java :: Loop Structure in Java 
Java :: java add com.google.guava dependancy maven 
Java :: WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable 
Java :: java map not null 
Java :: javafx location is required 
Java :: jframe visible 
Java :: bigdecimal to string 
Java :: change button text java 
Java :: javafx how to change shape color 
Java :: how to read input in java 
Java :: java const 
Java :: how to use input in java 
Java :: how to check whether a character is alphabet or not in java 
Java :: JAVA HashMap get keys by values 
Java :: how to get key value from json object in java 
Java :: contains hashmap java 
Java :: get driver mysql 
Java :: frequency of each element from list in java 
Java :: iterable interface in java 
Java :: set size button java 
Java :: android imageview set image from drawable programmatically 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =