Skip to content

Instantly share code, notes, and snippets.

@zakki
Created February 27, 2014 07:29
Show Gist options
  • Save zakki/9245879 to your computer and use it in GitHub Desktop.
Save zakki/9245879 to your computer and use it in GitHub Desktop.
FizzBuzz
public class Foo {
public static void main(String[] args) {
try {
if (new javax.script.ScriptEngineManager().getEngineByExtension("js").eval(
"var i = 1\n" +
"while (i < 100) {\n" +
"if (i % 15 == 0) println('FizzBuzz')\n" +
"else if (i % 3 == 0) println('Fizz')\n" +
"else if (i % 5 == 0) println('Buzz')\n" +
"else println(i)\n" +
"i++\n" +
"}\n"
) == null) {
}
} catch (javax.script.ScriptException e) {
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment