RuleBasedCollator clone() method in Java with Example Last Updated : 23 Aug, 2022 Comments Improve Suggest changes Like Article Like Report The clone() method of java.text.RuleBasedCollator class is used to get the copy of this Collator object.Syntax: public Object clone() Parameter: This method does not accept any parameter.Return Value: This method returns the copy of this Collator object.Below are the examples to illustrate the clone() method:Example 1: Java // Java program to demonstrate // clone() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { try { // Creating and initializing new simple rule String simple = "< a < b < c < d"; // Creating and initializing // new RuleBasedCollator Object RuleBasedCollator col = new RuleBasedCollator(simple); // getting copy of this object // using clone() method Object obj = col.clone(); // display result System.out.println("equivalent object :- " + obj); } catch (ClassCastException e) { System.out.println("Exception thrown : " + e); } catch (ParseException e) { System.out.println("Exception thrown : " + e); } } } Output: equivalent object :- java.text.RuleBasedCollator@7033e09a Example 2: Java // Java program to demonstrate // clone() method import java.text.*; import java.util.*; import java.io.*; public class GFG { public static void main(String[] argv) { try { // Creating and initializing new simple rule String simple = "< a < c & a < b"; // Creating and initializing // new RuleBasedCollator Object RuleBasedCollator col = new RuleBasedCollator(simple); // getting copy of this object // using clone() method Object obj = col.clone(); // display result System.out.println("equivalent object :- " + obj); } catch (ClassCastException e) { System.out.println("Exception thrown : " + e); } catch (ParseException e) { System.out.println("Exception thrown : " + e); } } } Output: equivalent object :- java.text.RuleBasedCollator@78930901 Reference: https://docs.oracle.com/javase/9/docs/api/java/text/RuleBasedCollator.html#clone-- Comment More infoAdvertise with us Next Article RuleBasedCollator clone() method in Java with Example R rohitprasad3 Follow Improve Article Tags : Java Java-Functions Java-text package Java-RuleBasedCollator Practice Tags : Java Similar Reads RuleBasedCollator compare() method in Java with Example The compare() method of java.text.RuleBasedCollator class is used to compare the strength of two objects and it will return 0, positive and negative value as an output according to the result. Syntax: public int compare(Object o1, Object o2) Parameter: This method takes two objects between which com 2 min read RuleBasedCollator equals() method in Java with Example The equals() method of java.text.Collator class is used to check if both the specified strings are identical or not. Syntax: public boolean equals(String source, String target) Parameter: This method takes two strings between which comparison is going to take place.Return Value: if both strings are 2 min read RuleBasedCollator getRules() method in Java with Example The getRules() method of java.text.RuleBasedCollator class is used to get the rule which is used during the initialization of rule based collator object. Syntax: public String getRules() Parameter: This method does not accept any argument as parameter.Return Value: This method returns the rule which 2 min read RuleBasedCollator hashCode() method in Java with Example The hashCode() method of java.text.RuleBasedCollator class is used to get the hashCode for this Collator object.Syntax: public abstract int hashCode() Parameter: This method does not accept any parameter.Return Value: This method returns hash code value in integer format.Below are the examples to il 2 min read NumberFormat clone() method in Java with Examples The clone() method is a built-in method of the java.text.NumberFormat returns a object which defines the clone of any given instance. Syntax: public Object clone() Parameters: The function does not accepts any parameter. Return Value: The function returns a object which defines the clone of any give 1 min read Like