RecursionLength.java
This program was created to get the length of words that are stored in a string.
The most embarrassing thing about this code is that it doesn’t use any recursion. That was due to the fact that it was merely a practice on using the length function from the string library.
Also, recursion was not taught at this point in time but rather taught later down the road.
The code has been modified slightly and now uploaded to the site.
Code Snippet
// Link to challenge: https://edabit.com/challenge/dGK2bxcojgLzbEZjp
public class RecursionLength {
public static void main(String[] args){
int result = length("apple");
int result2 = length("make");
int result3 = length("a");
int result4 = length("");
System.out.println(result);
System.out.println(result2);
System.out.println(result3);
System.out.println(result4);
}
public static int length(String str) {
int len = str.length();
return len;
}
}