javax.naming.CompositeName类的isEmpty()方法用于检查此复合名称对象是否为空。如果复合名称包含零个组成部分,则称该名称为空。
用法:
public boolean isEmpty()
参数:此方法不接受任何内容。
返回值:如果此复合名称为空,则此方法返回true,否则返回false。
下面的程序说明CompositeName.isEmpty()方法:
程序1:
// Java program to demonstrate
// CompositeName.isEmpty()
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("a/b/z/y/x");
// apply isEmpty()
boolean isEmpty
= CompositeName1.isEmpty();
// print value
System.out.println(
"This composite "
+ "object is empty:" + isEmpty);
}
}
输出:
This composite object is empty:false
程序2:
// Java program to demonstrate
// CompositeName.isEmpty() 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("");
// apply isEmpty()
boolean isEmpty
= CompositeName1.isEmpty();
// print value
System.out.println(
"This composite "
+ "object is empty:"
+ isEmpty);
}
}
输出:
This composite object is empty:true
参考文献:https://docs.oracle.com/javase/10/docs/api/javax/naming/CompositeName.html#isEmpty()
相关用法
- Java CompositeName get()用法及代码示例
- Java CompositeName add()用法及代码示例
- Java CompositeName equals()用法及代码示例
- Java CompositeName compareTo()用法及代码示例
- Java CompositeName clone()用法及代码示例
- Java CompositeName size()用法及代码示例
- Java CompositeName getAll()用法及代码示例
- Java CompositeName endsWith()用法及代码示例
- Java CompositeName toString()用法及代码示例
- Java CompositeName hashCode()用法及代码示例
- Java CompositeName getPrefix()用法及代码示例
- Java CompositeName startsWith()用法及代码示例
- Java CompositeName toString()用法及代码示例
- Java CompositeName addAll()用法及代码示例
- Java CompositeName remove()用法及代码示例
注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 CompositeName isEmpty() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。