Mega Code Archive

 
Categories / Java Tutorial / Data Type
 

Tokenizing a String

public class MainClass{   public static void main(String[] arg){     String text = "to be or not to be, that is the question.";     String[] words = text.split("[, .]", 0); // Delimiters are comma, space, or period          for(String s: words){       System.out.println(s);     }   } } to be or not to be that is the question