elementAt()

指定した位置の DtpSplitString オブジェクトのエレメントを戻します。

構文

String elementAt(int nth)
 

パラメーター

nth
DtpSplitString オブジェクトから抽出されるエレメントの位置。最初のエレメントの位置はゼロです。

戻り値

位置 nth にあるエレメントを含む String を戻します。

例外

DtpNoElementAtPositionException - nth に無効な位置を指定した場合です。

注記

エレメントには、ゼロから始まって、最初から最後まで番号が付けられます。例えば、区切り文字がコンマとスペースの場合、ストリング 「This,is a test」の位置 2 のエレメントは「a」になります。

elementAt() メソッドは、指定した位置のエレメントを戻しますが、現在のエレメントの位置は変更しません。

// Create a DtpSplitString object
 DtpSplitString MyString = new DtpSplitString("This,is a test",", ");
  
 //This call returns "a"
 public String MyString.elementAt(2);
 

参照項目

getElementCount()

Copyright IBM Corp. 2004