Java_字符串的分割

public class SplitString
{
	public static void main(String args[])
	{
		String str1 = "aaa,bbb,ccc,ddd";
		String str2[] = str1.split(",");//以,为界进行分割字符串
		System.out.println("结果数组str2的长度为:" + str2.length);//输出str2的长度
		System.out.println("结果数组str2的内容为:");
		for (int i=0; i<str2.length; ++i)
		{
			System.out.println(str2[i] + " ");
		}
		System.out.println("");//输出换行
		String str3 = "[email protected]@asd";
		Strint str4[] = str3.split("@163.com", 2);
		for (int i=0; i<str4.length; ++i)
		{
			System.out.println(str4[i]);
		}
	}
}

你可能感兴趣的:(Java_字符串的分割)