~ubuntu-branches/ubuntu/oneiric/swig1.3/oneiric

« back to all changes in this revision

Viewing changes to Examples/java/template/main.java

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2009-11-15 14:00:28 UTC
  • mfrom: (1.2.9 upstream) (2.1.4 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091115140028-me7amr2rie8zz1xn
Tags: 1.3.40-2ubuntu1
* Merge from Debian testing (LP: #356529), remaining changes:
  - Drop libchicken-dev from the build-depends (it's in universe)
  - Remove Pike from package description and from configure flags
  - drop "--without-mzscheme", we don't have it in our build-depends
  - use php-config5
  - Clean Runtime/ as well.
  - debian/rules (clean): Remove Lib/ocaml/swigp4.ml.
* debian/rules: Remove hardcoded python version.
* Remove upper limit for python from Build-Depends.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// This example illustrates how C++ templates can be used from Java.
2
 
 
3
 
public class main {
4
 
  static {
5
 
    try {
6
 
        System.loadLibrary("example");
7
 
    } catch (UnsatisfiedLinkError e) {
8
 
      System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
9
 
      System.exit(1);
10
 
    }
11
 
  }
12
 
 
13
 
  public static void main(String argv[]) 
14
 
  {
15
 
    // Call some templated functions
16
 
    System.out.println(example.maxint(3,7));
17
 
    System.out.println(example.maxdouble(3.14,2.18));
18
 
    
19
 
    // Create some class
20
 
    
21
 
    vecint iv = new vecint(100);
22
 
    vecdouble dv = new vecdouble(1000);
23
 
    
24
 
    for (int i=0; i<100; i++)
25
 
        iv.setitem(i,2*i);
26
 
    
27
 
    for (int i=0; i<1000; i++)
28
 
          dv.setitem(i, 1.0/(i+1));
29
 
    
30
 
    {
31
 
    int sum = 0;
32
 
    for (int i=0; i<100; i++)
33
 
          sum = sum + iv.getitem(i);
34
 
    
35
 
    System.out.println(sum);
36
 
    }
37
 
    
38
 
    {
39
 
    double sum = 0.0;
40
 
    for (int i=0; i<1000; i++)
41
 
          sum = sum + dv.getitem(i);
42
 
    System.out.println(sum);
43
 
    }
44
 
  }
45
 
}