diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
| commit | 7b21727285e50b0b050c4ddd70d07542229c5366 (patch) | |
| tree | 5d369153c5df5b41f3750d25479a68f20169c8ff /java | |
init
Diffstat (limited to 'java')
| -rw-r--r-- | java/Recursion.java | 16 | ||||
| -rwxr-xr-x | java/countWords.java | 14 |
2 files changed, 30 insertions, 0 deletions
diff --git a/java/Recursion.java b/java/Recursion.java new file mode 100644 index 0000000..88f4f0e --- /dev/null +++ b/java/Recursion.java @@ -0,0 +1,16 @@ +public class Recursion { + public static void main(String[] args) { + int x = 169; + int y = 2; + + System.out.println(recurse(x, y)); + + } + public static int recurse(int x, int y) { + if (x < y) { + return x; + } else { + return recurse(x - y, y); + } + } +}
\ No newline at end of file diff --git a/java/countWords.java b/java/countWords.java new file mode 100755 index 0000000..cd8ce98 --- /dev/null +++ b/java/countWords.java @@ -0,0 +1,14 @@ +import java.io.*; +import java.util.*; + +public class countWords { + public static void main(String[] args) throws FileNotFoundException { + Scanner fileScanner = new Scanner(new File(args[0])); + int count = 0; + while (fileScanner.hasNext()) { + count++; + String dummy = fileScanner.next(); + } + System.out.println(count); + } +} |
