import java.awt.Color;
import java.util.Random;
class TestJava {
public static void main(String[] args) {
Random rand = new Random();
// Java 'Color' class takes 3 floats, from 0 to 1.
float red = rand.nextFloat();
float green = rand.nextFloat();
float blue = rand.nextFloat();
Color randomColor = new Color(red, green, blue);
System.out.println(randomColor);
}
} |
import java.awt.Color;
import java.util.Random; class TestJava {
public static void main(String[] args) {
Random rand = new Random();
// Java 'Color' class takes 3 floats, from 0 to 1.
float red = rand.nextFloat();
float green = rand.nextFloat();
float blue = rand.nextFloat();
Color randomColor = new Color(red, green, blue);
System.out.println(randomColor);
}
}
Output:
java.awt.Color[r=232,g=230,b=101] |
java.awt.Color[r=232,g=230,b=101]