Split String in Java

Posted on Updated on

There are two ways to split string in Java.

  1. Using String.split(regex) method.
  2. Using StringTokenizer class.

Let us see how we can split the string in both ways.

1) Split String using String.split(regex) method


2) Split String using StringTokenizer


Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.