|
Last change
on this file since 2446 was 2, checked in by bird, 23 years ago |
|
Initial revision
|
-
Property cvs2svn:cvs-rev
set to
1.1
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
|
File size:
898 bytes
|
| Line | |
|---|
| 1 | public class ArrayStore
|
|---|
| 2 | {
|
|---|
| 3 | public static void main(String[] args)
|
|---|
| 4 | {
|
|---|
| 5 | ArrayStore s = new ArrayStore();
|
|---|
| 6 |
|
|---|
| 7 | /* Check that bounds check takes precedence over array store check. */
|
|---|
| 8 | try
|
|---|
| 9 | {
|
|---|
| 10 | s.a(new String[1]);
|
|---|
| 11 | }
|
|---|
| 12 | catch (Exception x)
|
|---|
| 13 | {
|
|---|
| 14 | System.out.println (x.getClass().getName());
|
|---|
| 15 | }
|
|---|
| 16 |
|
|---|
| 17 | try
|
|---|
| 18 | {
|
|---|
| 19 | s.a(new String[2]);
|
|---|
| 20 | }
|
|---|
| 21 | catch (Exception x)
|
|---|
| 22 | {
|
|---|
| 23 | System.out.println (x.getClass().getName());
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | /* Check that += operator on String[] element works and throws bounds
|
|---|
| 27 | exception. */
|
|---|
| 28 | try
|
|---|
| 29 | {
|
|---|
| 30 | s.b(new String[1]);
|
|---|
| 31 | }
|
|---|
| 32 | catch (Exception x)
|
|---|
| 33 | {
|
|---|
| 34 | System.out.println (x.getClass().getName());
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | String[] sb = new String[2];
|
|---|
| 38 | sb[1] = "foo";
|
|---|
| 39 | s.b(sb);
|
|---|
| 40 | System.out.println (sb[1]);
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | void a(Object[] oa)
|
|---|
| 44 | {
|
|---|
| 45 | oa[1] = new Integer(2);
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | void b(String[] sa)
|
|---|
| 49 | {
|
|---|
| 50 | sa[1] += "bar";
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.