Infolinks In Text Ads

Jul 1, 2010

what is StringIndexOutOfBoundsException in java code example

StringIndexOutOfBoundsException :-

StringIndexOutOfBoundsException is thrown by the String class,
if index in the string is passing greater then the string size
or negative value of index in string.

public class Test {
        public static void main(String[] args) {       
String str = "hello my friends";
            String str1 = str.substring(20);

 * Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -4
    at java.lang.String.substring(
    at java.lang.String.substring(
    at com.Test.main(

No comments:

Post a Comment


Related Posts Plugin for WordPress, Blogger...