I'd want to see if is possible to optimize performance even further of the following generate color method.
package generacolorrgb;
import java.util.Random;
public class GeneracolorRGB {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Random r = new Random();
for (int i = 0; i < 100; i++) {
System.out.println(generateColor(r));
}
}
private static String generateColor(Random r) {
StringBuilder color = new StringBuilder(Integer.toHexString(r
.nextInt(16777215)));
while (color.length() < 6) {
color.append("0");
}
return color.append("#").reverse().toString();
}
}
Average time it takes on my machine: 1650704.333 ns