Answers for "random mac address generator java"

0

random mac address generator java

//package com.java2s;
import java.util.Random;

public class Main {
    public static void main(String[] argv) throws Exception {
        System.out.println(getRandomMacAddress());
    }/*  w  w  w  .j  ava  2  s  .  c om*/

    public static String getRandomMacAddress() {
        String mac = "";
        Random r = new Random();
        for (int i = 0; i < 6; i++) {
            int n = r.nextInt(255);
            mac += String.format("%02x", n);
        }
        return mac.toUpperCase();
    }
}
Posted by: Guest on September-21-2020

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language