java随机生成十六进制颜色

java

 1 public static void main(String[] args) {

2

3 String r,g,b;

4 Random random = new Random();

5 r = Integer.toHexString(random.nextInt(256)).toUpperCase();

6 g = Integer.toHexString(random.nextInt(256)).toUpperCase();

7 b = Integer.toHexString(random.nextInt(256)).toUpperCase();

8

9 r = r.length()==1 ? "0" + r : r ;

10 g = g.length()==1 ? "0" + g : g ;

11 b = b.length()==1 ? "0" + b : b ;

12

13 System.out.println( r+g+b);;

14

15 }

3A9890

http://wandejun1012.iteye.com/blog/1179801

以上是 java随机生成十六进制颜色 的全部内容, 来源链接: utcz.com/z/390408.html

回到顶部