Java

Java - Exeption Handling(StringIndexOutOfBoundsException)

Java - Exeption Handling(StringIndexOutOfBoundsException)
// 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"); 
} 
} 
}
Senthilvelan Sambamoorthy

Senthilvelan Sambamoorthy is working as a Professor in Department of Master of Computer Applications, Paavai Engineering College, Namakkal, Tamilnadu, India, He is Masters in Computers Applications. Having 18+ years of experience and his area of interest is Java, JSP, Servlet, J2EE, C#, PHP, Python ASP.NET, SQL Server and etc.