Java tutorial
//package com.java2s; import java.util.Random; public class Main { private static String randomMac1() { String chars = "ABCDE0123456789"; String res = ""; Random rnd = new Random(); int leng = chars.length(); for (int i = 0; i < 17; i++) { if (i % 3 == 2) { res = res + ":"; } else { res = res + chars.charAt(rnd.nextInt(leng)); } } return res; } }