How to use the split () function and the trim () function
This address: http://blog.csdn.net/caroline_wendy/article/details/24465141
Detailed reference Java API: http://docs.oracle.com/javase/6/docs/api/java/lang/String.html
The split () function is based on the parameters such as ",", "-", "", and so on, cutting string strings , returning an array of string (string[]), and being able to specify the elements by index.
If not found, the entire string string is returned as the No. 0 element of the string array (string[]).
The trim () function is a trailing space that removes string strings;
Code:
/** * @author Spike * @time 2014.4.25 */public class Split {public static void split () {String details = "M 2.9-9km W of Alberto Oviedo Mota, Mexico "; String magnitudestring = Details.split ("") [1]; System.out.println (magnitudestring);d etails = Details.split (",") [1].trim (); SYSTEM.OUT.PRINTLN (details);} public static void Main (string[] args) {//TODO auto-generated method Stubsplit ();}}
Output:
2.9Mexico
How to use the Java-split () function and the trim () function