June 2018
Beginner
722 pages
18h 47m
English
The methods String[] split(String regex) and String[] split(String regex, int limit) use the passed-in regular expression to split the strings into substrings. We do not explain regular expressions in this book. However, there is a very simple one that is easy to use even if you know nothing about regular expressions: if you just pass into this method any symbol or substring present in a string, the string will be broken (split) into parts separated by the passed-in value, for example:
String[] substrings = "Introduction".split("o");System.out.println(Arrays.toString(substrings)); //prints: [Intr, ducti, n]substrings = "Introduction".split("duct");System.out.println(Arrays.toString(substrings)); //prints: [Intro, ...
Read now
Unlock full access