Java Locale.clone()

Syntax

Locale.clone() has the following syntax.

public Object clone()

Example

In the following code shows how to use Locale.clone() method.


import java.util.Locale;
//  www  . java  2s. com
public class Main {

   public static void main(String[] args) {
      Locale locale1 = new Locale("ENGLISH", "US");

      // print this locale
      System.out.println("Locale1:" + locale1);

      // create a second locale
      Locale locale2;

      // clone locale1 to locale2
      locale2 = (Locale) locale1.clone();

      System.out.println("Locale2:" + locale2);
   }
}

The code above generates the following result.