prevElement()

Returns the previous element in the DtpSplitString object.

Syntax

String prevElement()
 

Return values

Returns a String containing the previous element.

Exceptions

DtpNoElementAtPositionException - If there is no previous element.

Notes

You can use prevElement(), along with nextElement(), to navigate the elements (tokens) in a DtpSplitString object. The first time you call nextElement(), the element position is zero. Subsequent calls to nextElement()increment the position by one. The prevElement() method returns the previous element and decrements the element position by one.

Examples

// Create a DtpSplitString object
 DtpSplitString MyString = new DtpSplitString("This,is a test",", ");
  
 // This call returns element 0 containing "This"
 String firstElement = MyString.nextElement()
  
 // This call returns element 1 containing "is"
 String secondElement = MyString.nextElement()
  
 // This call returns element 0 containing "This"
 String anotherElement = MyString.prevElement()
 

See also

nextElement()

Copyright IBM Corp. 1997, 2003