Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

substring method

 
Conrad Kirby
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look:

I know this will throw an outofbounds exception but will it return ""?
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Conrad,
Your question is moot because the JVM specifies the following.

When an exception is thrown, control is transferred from the code that caused the exception to the nearest dynamically-enclosing catch clause of a try statement (�14.19) that handles the exception.

Since your code is not inside a try/catch block program control will go out of the method you are in to find one. If none is found the the JVM will stop your application/applet.
Regards,
Manfred.
 
rani bedi
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried compiling it but didn't got any exception.
I think string2 gets initialized to a newly created String object so that it represents an empty character sequence.
String string2 = new String();
 
Conrad Kirby
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, does it return ""? I guess I don't know a lot about excepions.
 
Conrad Kirby
Ranch Hand
Posts: 178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanx parameet. I forgot to show that the block of code was in a try statement. But as long as it returns "", i don't need a try statement.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic