Skip to content

Instantly share code, notes, and snippets.

View Bravo6nteringtheroom's full-sized avatar

Oboy Bravo6nteringtheroom

View GitHub Profile
@Bravo6nteringtheroom
Bravo6nteringtheroom / RecursiveStringLength.java
Created December 1, 2025 22:48
Yeah guys sorry i know i used try-catch in order to do this but it was just to solve the index out of bounds error any suggestion how to deal with that But to be honest it really helped me understand more about recursion and who knows maybe i'll do the same for other functions
public class RecursiveStringLength {
static int len(String word, int n) {
try {
if(word.charAt(n) == ' ') return n;
return len(word, n+1);
} catch(IndexOutOfBoundsException e) {
return n;
}
}