±Û¾´ÀÌ :Sung Yi 2000³â 2¿ù 08ÀÏ 06:02:24
In Reply to: [Áú¹®]run-time ½Ã¿¡ ¿¹¿Üó¸®ÇÏ´Â ¹æ¹ýÀÖ³ª¿ä? posted by ¹ÚÀçÇü on 2000³â 2¿ù 07ÀÏ 17:29:26:
I think that you are doing just fine. That is the right way to catch a runtime error. The only program that I see is in the catch block declaration.
It should be
catch(IndexOutOfBoundException yourOwnVar){
}
Or, if you prefer, you can check the strings before processing.
if((temp1=str.indexOf("test")) >= 0 && (temp2=str.indexOf("program")) >= 0){
temp = str.substring(temp1, temp2);
If you wish to continue processing no matter what the outcome is, you can use the finally{} block.