Here you can find the source of randomColor()
public static String randomColor()
//package com.java2s; //License from project: Open Source License public class Main { private static final String[] letters = "0123456789ABCDEF".split(""); public static String randomColor() { StringBuilder colorBuilder = new StringBuilder(); colorBuilder.append('#'); for (int i = 0; i < 6; i++) { Double position = Math.floor(Math.random() * 16); colorBuilder.append(letters[position.intValue()]); }// ww w . j av a 2 s . c o m return colorBuilder.toString(); } }