String.split returns an array so you got to use the return value by indexing the differents "cells" to get them.
StringTokenizer is a class that permits a different acces to the values. In fact, it depends on what you want to do with slited data. If you want to acces it sequentially, use StringTokenizer and its "hasmoretokens" and "nextToken" methods. If you want to access it randomly, use split because you can, this way access directly the "cell" you want.
Another difference is in the delimiter used to split. With String.split, you can use regExp to cut your string, with StringTokenizer, you can provide one or more chars as delimiters.
Hope that helps. Water is not bad as long as it stays out human body ;-)
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.