StringIndexOutOfBoundsException

<span style="font-family:Microsoft YaHei;font-size:14px;">public class StringIndexBoundsExceptionTest {
	
	@Test
	public void test(){
		String str = "h";
		String a = "wfe";
		System.out.println(str.substring(1));//抛出异常StringIndexBoundsException
		System.out.println(a.substring(1, 1));//正常显示
		System.out.println(a.substring(1, 0));//抛出异常StringIndexBoundsException
	}

}</span>

posted @ 2017-06-06 18:20  yxysuanfa  阅读(570)  评论(0编辑  收藏  举报