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>

原文地址:https://www.cnblogs.com/yxysuanfa/p/6952988.html