javax.naming.CompositeName類的getAll()方法用於返回此複合對象的所有組件,作為字符串的枚舉。在此枚舉上應用於此組合名稱的更新效果是不確定的。
用法:
public Enumeration getAll()
參數:此方法不接受任何內容。
返回值:此方法返回此複合名稱的組成部分的非null枚舉。枚舉的每個元素都是String類。
下麵的程序說明CompositeName.getAll()方法:
程序1:
// Java program to demonstrate
// CompositeName.getAll()
import java.util.Enumeration;
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 CompositeName
= new CompositeName("a/b/z/y/x");
// apply getAll()
Enumeration<String> components
= CompositeName.getAll();
// print value
while (components.hasMoreElements()) {
System.out.println("Component:"
+ components.nextElement());
}
}
}
程序2:
// Java program to demonstrate
// CompositeName.getAll() method
import java.util.Enumeration;
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 CompositeName
= new CompositeName("ca/ea/dz/y/x/f");
// apply getAll()
Enumeration<String> components
= CompositeName.getAll();
// print value
int i = 0;
while (components.hasMoreElements()) {
System.out.println("position "
+ i + ":"
+ components.nextElement());
i++;
}
}
}
參考文獻:https://docs.oracle.com/javase/10/docs/api/javax/naming/CompositeName.html#getAll()
相關用法
- Java CompoundName getAll()用法及代碼示例
- Java CompositeName add()用法及代碼示例
- Java CompositeName get()用法及代碼示例
- Java CompositeName hashCode()用法及代碼示例
- Java CompositeName endsWith()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName remove()用法及代碼示例
- Java CompositeName isEmpty()用法及代碼示例
- Java CompositeName addAll()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName getSuffix()用法及代碼示例
- Java CompositeName getPrefix()用法及代碼示例
- Java CompositeName clone()用法及代碼示例
- Java CompositeName size()用法及代碼示例
- Java CompositeName compareTo()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 CompositeName getAll() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。