Questionsforum
What is the difference between split and StringTokeniser ?

What is the difference between split and StringTokeniser ?



On 2014-06-26 03:39:29.0
hablu


Split() :-

  1. It return String[] array, which is always required.
  2. Syntax is easy to use.
  3. Works with the Regular Expression so there may have chance to read the spaces as well.
  4. Its a bit slower than StringTokenizer

StringTokenizer :-

  1. It returns the String (a token) at a time using Enumeration internally for storing the token.
  2. Syntax is not as simple as compared to split() .
  3. Works with the delimiter which itself is a string and no chance of counting spaces unless we are not indicating.
  4. It is a bit faster than split().


On 2014-06-26 10:51:37.0
sushant

split() will split the given string on the basis of regular exp that you can take in string format. While StringTokenizer will split the given string character wise.

how can you say that split() is slower as compared to StringTokeniser ?



On 2014-06-26 12:20:10.0
hablu

I think not checking for the space in case of StringTokenizer unless we tell to check for the space in the String, it reduces the time and even space.



On 2014-06-27 09:18:46.0
sushant

copyright@questionsforum.net