-
-
Save olafleur/16bbafe6babd7ddc5bf8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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