Java唯一的标识符

 

一、使用java.rmi.dgc.VMID

 

public class Main {
  public static void main(String arg[]) {
    System.out.println(new java.rmi.dgc.VMID().toString());
  }
}
//4129eb1d7419293f:-148094f1:11fc9788387:-8000

 

二、使用java.util.UUID

import java.util.UUID;

public class Main {
  public static void main(String arg[]) {
    System.out.println(UUID.randomUUID());
  }
}
//138a4222-e898-484f-8347-dafc01c5b03b

 

 

你可能感兴趣的:(java)