javax.naming.CompositeName類的size()方法用於返回組合名稱對象的大小,該大小等於此組合名稱中的組件數。
用法:
public int size()
參數:此方法不接受任何內容。
返回值:此方法以此組合名稱返回非負數的組件。
下麵的程序說明CompositeName.size()方法:
程序1:
// Java program to demonstrate
// CompositeName.size()
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/7/8/9/0");
// apply size()
int size = CompositeName1.size();
// print value
System.out.println("size:"
+ size);
}
}
輸出:
size:10
程序2:
// Java program to demonstrate
// CompositeName.size() 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/y/x/f");
// apply size()
int size = CompositeName1.size();
// print value
System.out.println("size:" + size);
}
}
輸出:
size:8
參考文獻:https://docs.oracle.com/javase/10/docs/api/javax/naming/CompositeName.html#size()
相關用法
- Java CompositeName get()用法及代碼示例
- Java CompositeName add()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName startsWith()用法及代碼示例
- Java CompositeName getSuffix()用法及代碼示例
- Java CompositeName endsWith()用法及代碼示例
- Java CompositeName isEmpty()用法及代碼示例
- Java CompositeName remove()用法及代碼示例
- Java CompositeName addAll()用法及代碼示例
- Java CompositeName compareTo()用法及代碼示例
- Java CompositeName toString()用法及代碼示例
- Java CompositeName getPrefix()用法及代碼示例
- Java CompositeName hashCode()用法及代碼示例
- Java CompositeName clone()用法及代碼示例
- Java CompositeName getAll()用法及代碼示例
注:本文由純淨天空篩選整理自AmanSingh2210大神的英文原創作品 CompositeName size() method in Java with Examples。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。