Showing posts with label For. Show all posts
Showing posts with label For. Show all posts

Wednesday, May 23, 2012

The split function

DOWNLOAD THE CODE: usingSplit.java.zip

The String class contains a split() function. This means that any single string may be split into several substrings, based upon a nominated delimiter character. split() returns an array of String, containing each substring.

Example 1: split a string using a space as the delimiter:

Output:



Example 2: split a string using a comma (,) as the delimiter:

Output:





Tuesday, April 17, 2012

For-each Loop


"Java: For-each Loop" ( http://bit.ly/HThpAk )


For each Line in the array called myLine.