elementAt()

Returns an element in the DtpSplitString object at the position you specify.

Syntax

String elementAt(int nth)
 

Parameters

nth
The position of the element to extract from the DtpSplitString object. The position of the first element is zero.

Return values

Returns a String containing the element at the nth position.

Exceptions

DtpNoElementAtPositionException - If you specify an invalid position for nth.

Notes

Elements are numbered from first to last beginning with zero. For example, if the delimiters are commas and spaces, then the element at position two in the string, "This,is a test" is "a".

The elementAt() method returns the element at the specified position but does not change the current element position.

Examples

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

See also

getElementCount()

Copyright IBM Corp. 1997, 2003