User Tools

Site Tools


java:numerosaleatorios

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

java:numerosaleatorios [2014/12/24 10:42] (current)
Line 1: Line 1:
 +====== Cómo crear y generar números aleatorios ======
 +
 +[[http://​java.sun.com/​javase/​6/​docs/​api/​java/​util/​Random.html]]
 +
 +<code java>
 +import java.util.Random; ​
 +
 +Random rnd = new Random(); ​
 +
 +rnd.nextInt( 5 );  // devuelve un número entero aleatorio entre 0 y 4 
 +
 +rnd.nextLong();​ // retorna un entero largo 
 +
 +</​code>​
 +
  
java/numerosaleatorios.txt · Last modified: 2014/12/24 10:42 (external edit)