CompositeName endsWith() method in Java with Examples Last Updated : 27 Mar, 2020 Comments Improve Suggest changes Like Article Like Report The endsWith() method of a javax.naming.CompositeName class is used to check whether composite name which is passed as a parameter is a suffix of this composite name or not. A composite name 'X' is a suffix of this composite name if this composite name object ends with 'X'. If X is null or not a composite name object, false is returned. Syntax: public boolean endsWith(Name n) Parameters: This method accepts n which is the possibly null composite name to check. Return value: This method returns true if n is a CompositeName and is a suffix of this composite name, false otherwise. Below programs illustrate the CompositeName.endsWith() method: Program 1: Java // Java program to demonstrate // CompositeName.endsWith() import java.util.Properties; import javax.naming.CompositeName; import javax.naming.InvalidNameException; public class GFG { public static void main(String[] args) throws InvalidNameException { // create composite name object CompositeName CompositeName1 = new CompositeName("1/2/3/4/5/6"); CompositeName CompositeName2 = new CompositeName("5/6"); // apply endsWith() boolean endWithFlag = CompositeName1.endsWith(CompositeName2); // print value if (endWithFlag) System.out.println("CompositeName1 ends with " + " CompositeName2"); else System.out.println("CompositeName1 not ends with " + " CompositeName2"); } } Output: CompositeName1 ends with CompositeName2 Program 2: Java // Java program to demonstrate // CompositeName.endsWith() method import java.util.Properties; import javax.naming.CompositeName; import javax.naming.InvalidNameException; public class GFG { public static void main(String[] args) throws InvalidNameException { // create composite name object CompositeName CompositeName1 = new CompositeName("c/e/d/v/a/b/z/y/x/f"); CompositeName CompositeName2 = new CompositeName("z/y/x"); // apply endsWith() boolean endWithFlag = CompositeName1.endsWith(CompositeName2); // print value if (endWithFlag) System.out.println("CompositeName1 ends with " + " CompositeName2"); else System.out.println("CompositeName1 not ends with " + " CompositeName2"); } } Output: CompositeName1 not ends with CompositeName2 References: https://docs.oracle.com/javase/10/docs/api/javax/naming/CompositeName.html#endsWith(javax.naming.Name) Comment More infoAdvertise with us Next Article CompoundName endsWith() method in Java with Examples A AmanSingh2210 Follow Improve Article Tags : Java Java-Functions Practice Tags : Java Similar Reads CompoundName endsWith() method in Java with Examples The endsWith() method of a javax.naming.CompoundName class is used to check whether compound name which is passed as a parameter is a suffix of this compound name or not. A compound name 'X' is a suffix of this compound name if this compound name object ends with 'X'. If X is null or not a compound 2 min read CompositeName get() method in Java with Examples The get() method of a javax.naming.CompositeName class is used to get a component of this composite name object.The position passed as a parameter used to get the component present at that position from the composite name object. Syntax: public String get(int posn) Parameters: This method accepts po 2 min read CompositeName toString() method in Java with Examples The toString() method of a javax.naming.CompositeName class is used to create the string representation of this composite name object, using the syntax "/" as a separator of each object. The string representation returned by this composite name consists of enumerating in order each component of this 2 min read CompositeName toString() method in Java with Examples The toString() method of a javax.naming.CompositeName class is used to create the string representation of this composite name object, using the syntax "/" as a separator of each object. The string representation returned by this composite name consists of enumerating in order each component of this 2 min read CompositeName startsWith() method in Java with Examples The startsWith() method of a javax.naming.CompositeName class is used to check whether composite name which is passed as a parameter is a prefix of this composite name or not. A composite name 'X' is a prefix of this composite name if this composite name object ends with 'X'. If X is null or not a c 2 min read Path endsWith() method in Java with Examples endswith() method of java.nio.file.Path used to check if this path object ends with the given path or string which we passed as parameter. There are two types of endsWith() methods. endsWith(String other) method of java.nio.file.Path used to check if this path ends with a Path, constructed by conver 3 min read Like