[3029] in java-interest
Re: String.substring lies about what exceptions is throws
daemon@ATHENA.MIT.EDU (Huizhao Wang)
Fri Oct 27 03:00:35 1995
To: huizhao@krypton.Stanford.EDU
Cc: java-interest@java.Eng.Sun.COM
From: huizhao@krypton.Stanford.EDU (Huizhao Wang)
Date: Fri, 27 Oct 95 22:41:02
In-Reply-To: <199510270143.SAA03977@6108-news.jakarta.Eng.Sun.COM>
In article <199510270143.SAA03977@6108-news.jakarta.Eng.Sun.COM>, you
say...
>
>
>Hi Jon,
>
>> public String substring(int beginIndex, int endIndex) {
>> if (beginIndex > endIndex) {
>> int tmp = beginIndex;
>> beginIndex = endIndex;
>> endIndex = tmp;
>> }
>> if (beginIndex < 0) {
>> throw new StringIndexOutOfBoundsException(beginIndex);
>> }
>> if (endIndex > count) {
>> throw new StringIndexOutOfBoundsException(endIndex);
>> }
>> return ((beginIndex == 0) && (endIndex == count)) ? this :
>> new String(value, offset + beginIndex, endIndex -
beginIndex);
>> }
>>
>> It doesn't declare it's throwing any exceptions ... Was the prebeta
>> release compiled with the prebeta compiler? I think not.
>
>You don't have to declare RuntimeExceptions.
StringIndexOutOfBoundsException is
>a subclass of RuntimeException.
>
>Have fun,
>
> Arthur van Hoff
>-
>This message was sent to the java-interest mailing list
>Info: send 'help' to java-interest-request@java.sun.com
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com