diff options
Diffstat (limited to 'tutorial/examples/freeargs/Collection.java')
-rw-r--r-- | tutorial/examples/freeargs/Collection.java | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/tutorial/examples/freeargs/Collection.java b/tutorial/examples/freeargs/Collection.java new file mode 100644 index 0000000..74fff0f --- /dev/null +++ b/tutorial/examples/freeargs/Collection.java @@ -0,0 +1,61 @@ +/* + * This code was generated by ojc. + */ +/* + * Collection.oj + * + * Apr 13, 1999 Michiaki Tatsubori + */ +package examples.freeargs; + + +import examples.freeargs.FreeArgsClass; +import examples.print.*; + + +/** + * The class <code>Collection</code> represents a collection of objects. + */ +public class Collection +{ + + private java.lang.Object[] contents; + + public Collection() + { + contents = new java.lang.Object[0]; + } + + public boolean isEmpty() + { + return contents.length == 0; + } + + /** Accepts any number of arguments. */ + public void set( java.lang.Object[] args ) + { + contents = new java.lang.Object[args.length]; + System.arraycopy( args, 0, contents, 0, args.length ); + } + + /** Accepts any number of arguments. */ + public void add( java.lang.Object[] args ) + { + java.lang.Object[] old = contents; + contents = new java.lang.Object[old.length + args.length]; + System.arraycopy( old, 0, contents, 0, old.length ); + System.arraycopy( args, 0, contents, old.length, args.length ); + } + + public int size() + { + return contents.length; + } + + /** Obtains a specified object. */ + public java.lang.Object get( int i ) + { + return contents[i]; + } + +} |