|
Last change
on this file since 3103 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:
1.1 KB
|
| Line | |
|---|
| 1 | // Class anon
|
|---|
| 2 | // Generated on Wed Dec 29 10:07:09 PST 1999
|
|---|
| 3 | //
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 | interface itf {int count = 0;void setCount (int i);int getCount ();}
|
|---|
| 7 |
|
|---|
| 8 | class anon {
|
|---|
| 9 |
|
|---|
| 10 | int count = 34;
|
|---|
| 11 |
|
|---|
| 12 | class x implements itf {
|
|---|
| 13 | int count = 3;
|
|---|
| 14 | public void setCount (int j) { }
|
|---|
| 15 | public int getCount () { return count*3; }
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | itf foo () {
|
|---|
| 20 | class y implements itf {
|
|---|
| 21 | int count = 3;
|
|---|
| 22 | public void setCount (int j) { count = j; }
|
|---|
| 23 | public int getCount () { return count+1; }
|
|---|
| 24 | }
|
|---|
| 25 | return new y ();
|
|---|
| 26 | }
|
|---|
| 27 |
|
|---|
| 28 | itf bar () {
|
|---|
| 29 | return new itf () {
|
|---|
| 30 | // The class defined right here will implement `itf'
|
|---|
| 31 | int count = 5;
|
|---|
| 32 | public void setCount (int j) { count = j; }
|
|---|
| 33 | public int getCount () { return count+1; }
|
|---|
| 34 | } ;
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 | void test () {
|
|---|
| 38 | itf a = foo ();
|
|---|
| 39 | itf b = bar ();
|
|---|
| 40 | x c = this.new x ();
|
|---|
| 41 | System.out.println (a.getCount ());
|
|---|
| 42 | System.out.println (b.getCount ());
|
|---|
| 43 | System.out.println (c.getCount ());
|
|---|
| 44 | System.out.println (this.count);
|
|---|
| 45 | }
|
|---|
| 46 |
|
|---|
| 47 | public static void main (String[] arg)
|
|---|
| 48 | {
|
|---|
| 49 | System.out.println ("Testing class `anon'...");
|
|---|
| 50 | new anon ().test ();
|
|---|
| 51 | }
|
|---|
| 52 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.