java.util.UUID.fromString() Method
Advertisements
Description
The fromString(String name) method is used to create a UUID from the string standard representation as described in the toString() method.
Declaration
Following is the declaration for java.util.UUID.fromString() method.
public static UUID fromString(String name)
Parameters
name--This is a string that specifies a UUID.
Return Value
The method call returns a UUID with the specified value.
Exception
IllegalArgumentException--This exception is thrown if the name does not conform to the string representation as described in toString().
Example
The following example shows the usage of java.util.UUID.fromString()
package com.tutorialspoint;
import java.util.*;
public class UUIDDemo {
public static void main(String[] args) {
// creating UUID
UUID uid = UUID.fromString("38400000-8cf0-11bd-b23e-10b96e4ef00d");
// checking UUID value
System.out.println("UUID value is: "+uid);
}
}
Let us compile and run the above program, this will produce the following result.
UUID value is: 38400000-8cf0-11bd-b23e-10b96e4ef00d