1 /* |
1 /* |
2 * Copyright (c) 1994, 2012, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1994, 2015, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
24 */ |
24 */ |
25 |
25 |
26 package java.lang; |
26 package java.lang; |
27 |
27 |
28 /** |
28 /** |
29 * Thrown by {@code String} methods to indicate that an index |
29 * Thrown by {@code String} methods to indicate that an index is either negative |
30 * is either negative or greater than the size of the string. For |
30 * or greater than the size of the string. For some methods such as the |
31 * some methods such as the charAt method, this exception also is |
31 * {@link String#charAt charAt} method, this exception also is thrown when the |
32 * thrown when the index is equal to the size of the string. |
32 * index is equal to the size of the string. |
33 * |
33 * |
34 * @author unascribed |
34 * @see java.lang.String#charAt(int) |
35 * @see java.lang.String#charAt(int) |
35 * @since 1.0 |
36 * @since 1.0 |
|
37 */ |
36 */ |
38 public |
37 public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException { |
39 class StringIndexOutOfBoundsException extends IndexOutOfBoundsException { |
|
40 private static final long serialVersionUID = -6762910422159637258L; |
38 private static final long serialVersionUID = -6762910422159637258L; |
41 |
39 |
42 /** |
40 /** |
43 * Constructs a {@code StringIndexOutOfBoundsException} with no |
41 * Constructs a {@code StringIndexOutOfBoundsException} with no detail |
44 * detail message. |
42 * message. |
45 */ |
43 */ |
46 public StringIndexOutOfBoundsException() { |
44 public StringIndexOutOfBoundsException() { |
47 super(); |
45 super(); |
48 } |
46 } |
49 |
47 |
50 /** |
48 /** |
51 * Constructs a {@code StringIndexOutOfBoundsException} with |
49 * Constructs a {@code StringIndexOutOfBoundsException} with the specified |
52 * the specified detail message. |
50 * detail message. |
53 * |
51 * |
54 * @param s the detail message. |
52 * @param s the detail message. |
55 */ |
53 */ |
56 public StringIndexOutOfBoundsException(String s) { |
54 public StringIndexOutOfBoundsException(String s) { |
57 super(s); |
55 super(s); |
58 } |
56 } |
59 |
57 |
60 /** |
58 /** |
61 * Constructs a new {@code StringIndexOutOfBoundsException} |
59 * Constructs a new {@code StringIndexOutOfBoundsException} class with an |
62 * class with an argument indicating the illegal index. |
60 * argument indicating the illegal index. |
63 * |
61 * |
64 * @param index the illegal index. |
62 * <p>The index is included in this exception's detail message. The |
|
63 * exact presentation format of the detail message is unspecified. |
|
64 * |
|
65 * @param index the illegal index. |
65 */ |
66 */ |
66 public StringIndexOutOfBoundsException(int index) { |
67 public StringIndexOutOfBoundsException(int index) { |
67 super("String index out of range: " + index); |
68 super("String index out of range: " + index); |
68 } |
69 } |
|
70 |
|
71 /** |
|
72 * Constructs a new {@code StringIndexOutOfBoundsException} class with |
|
73 * arguments indicating two out of bound values. |
|
74 * |
|
75 * <p>The out of bound values are included in this exception's detail |
|
76 * message. The exact presentation format of the detail message is |
|
77 * unspecified. |
|
78 * |
|
79 * @param a the first out of bound value. |
|
80 * @param b the second out of bound value. |
|
81 * @since 9 |
|
82 */ |
|
83 public StringIndexOutOfBoundsException(int a, int b) { |
|
84 super("String indexed access out of bounds: " + a + ", " + b); |
|
85 } |
69 } |
86 } |