日期:2014-05-20  浏览次数:20780 次

Split问题
public   class   c
{
public   static   void   main(String   []   args)
{
String   email   =   "2451@163.com ";
String   []   str   =   email.split( "@ ");
System.out.println(str[0]);
System.out.println(str[1]);
String   []   str2   =   str[1].split( ". ");
System.out.println(str2[0]);
System.out.println(str2[1]);
}
}

为什么数组下标越界

------解决方案--------------------
public class c
{
public static void main(String [] args)
{
String email = "2451@163.com ";
String [] str = email.split( "@ ");
System.out.println(str[0]);
System.out.println(str[1]);
String [] str2 = str[1].split( "\\. ");
System.out.println(str2[0]);
System.out.println(str2[1]);
}
}