aboutsummaryrefslogtreecommitdiffstats
path: root/sample/vector/Test.j
blob: 4ae7f6b67a484e2aa5ee518d13747b36b44e224b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
  A sample program using sample.vector.VectorAssistant
  and the sample.preproc package.

  This automatically produces the classes representing vectors of integer
  and vectors of java.lang.String.

  To compile and run this program, do as follows:

    % java sample.preproc.Compiler sample/vector/Test.j
    % javac sample/vector/Test.java
    % java sample.vector.Test

  The first line produces one source file (sample/Test.java) and
  two class files (sample/vector/intVector.class and
  sample/vector/StringVector.class).
*/

package sample.vector;

import java.util.Vector by sample.vector.VectorAssistant(java.lang.String);
import java.util.Vector by sample.vector.VectorAssistant(int);

public class Test {
    public static void main(String[] args) {
	intVector iv = new intVector();
	iv.add(3);
	iv.add(4);
	for (int i = 0; i < iv.size(); ++i)
	    System.out.println(iv.at(i));

	StringVector sv = new StringVector();
	sv.add("foo");
	sv.add("bar");
	for (int i = 0; i < sv.size(); ++i)
	    System.out.println(sv.at(i));
    }
}