Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// in JavaScript
com = { acme: {} };
com.acme.Foo = function() {
this.x = 40;
this.y = 2;
};
com.acme.Foo.prototype.sum = function() { return this.x + this.y; };
// in Java
package com.acme;
@JsType(isNative = true)
class Foo {
public int x;
public int y;
public native int sum();
}
class FooMain {
public static void main() {
Foo foo = new Foo();
foo.sum(); // will return 42!
foo.x = 50;
foo.y = 5;
foo.sum(); // will return 55!
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment