lastElement()

Returns the last element in the DtpSplitString object.

Syntax

String lastElement()
 

Return values

Returns a String containing the last element.

Exceptions

DtpNoElementAtPositionException - If there are no elements.

Notes

Elements are numbered from first to last beginning with zero. The last element is the highest-numbered element. The position number of the last element is equivalent to getElementCount()-1.

The lastElement() method returns the last element but does not change the current element position.

Examples

// Create a DtpSplitString object
 DtpSplitString MyString = new DtpSplitString("This,is a test",", ");
  
 // This call returns the last element, containing "test"
 String anElement = MyString.lastElement();
 

See also

firstElement(), getElementCount()

Copyright IBM Corp. 2003