当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Java CompositeName getAll()用法及代码示例


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()




相关用法


注:本文由纯净天空筛选整理自AmanSingh2210大神的英文原创作品 CompositeName getAll() method in Java with Examples。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。