StringTokenizer pSpaceDelim = new StringTokenizer( "This is a text." ); System.out.println( "Count = " + pSpaceDelim.countTokens() + System.lineSeparator() ); while ( pSpaceDelim.hasMoreTokens() ) System.out.println( pSpaceDelim.nextToken() );Output:
Count = 4 This is a text.NOTE: System.lineSeparator() is system dependent line separator.
No comments:
Post a Comment