Q:

Java - Exeption Handling(StringIndexOutOfBoundsException)

0

This Program is used to demonstrate the Exception Handling StringIndexOutOfBoundsException.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

// StringIndexOutOfBoundsException 

class StrEx 
{ 
public static void main(String args[]) 
{ 
try 
{ 
String str="Senthilvelan"; 
System.out.println(str.length());; 

char c = str.charAt(0); 
c = str.charAt(20); 
System.out.println("\n"+c); 
} 
catch(StringIndexOutOfBoundsException e) 
{ 
System.out.println("\nStringIndexOutOfBoundsException : less than of the given String"); 
} 
} 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now