|
Some content modified from the Java Tutorials at http://java.sun.com/docs/books/tutorial/java/data/strings.html Fundamentally, a String is a sequence of characters. The String class provides various methods to access portions of a String, but recall that Strings are immutable . That means that they do not change. To morph one String into another, you must use methods to create a new String object containing the new set of characters. Common MethodsFollowing are several common methods that are fairly self-explanatory. Take a look at the String API for a bit more detail.
The split MethodThe split method can be used to divide a String into several substrings. It takes as input a regular expression denoting the how the string should be split and returns an array of Strings. In the simplest case, the expression is a character denoting the delimiter to be used. The following example splits the String around the colon. The result is an array of Strings - [a,b,c]. Note that the delimiter is removed from the result. |