File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes substring method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "substring method" Watch "substring method" New topic
Author

substring method

Conrad Kirby
Ranch Hand

Joined: Jun 17, 2001
Posts: 178
Look:

I know this will throw an outofbounds exception but will it return ""?
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
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

Joined: Feb 06, 2001
Posts: 358
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();


Cheers,<br />Rani<br />SCJP, SCWCD, SCBCD
Conrad Kirby
Ranch Hand

Joined: Jun 17, 2001
Posts: 178
Well, does it return ""? I guess I don't know a lot about excepions.
Conrad Kirby
Ranch Hand

Joined: Jun 17, 2001
Posts: 178
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: substring method