Created
December 9, 2011 15:06
-
-
Save jponge/1451867 to your computer and use it in GitHub Desktop.
A "factorial" module
This file contains hidden or 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
mkdir -p sources/fact/fact | |
mkdir modules | |
# edit the files! | |
javac -d modules -modulepath modules \ | |
-sourcepath sources \ | |
sources/fact/module-info.java \ | |
sources/fact/fact/Factorial.java |
This file contains hidden or 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
package fact; | |
public class Factorial { | |
public static int factorial(int n) { | |
if (n <= 0) { return 1; } | |
else { return n * factorial(n - 1); } | |
} | |
} |
This file contains hidden or 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
module fact @1.0 { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment