Thomas Kasene

Greenhorn
+ Follow
since Feb 21, 2013
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by Thomas Kasene

Hey there,

As with any recursive method, there are two ways to end it: either by getting a StackOverflowError or an OutOfMemoryError, or by having a base case in your method. You'll get the errors when the method calls itself so many times that the program reaches its limits in terms of memory usage and/or callstack size, which typically happens when the method never reaches any of its base cases.

In your code, the if-block checking whether rest.isEmpty() is the base case. As far as I can tell, however, the rest list is never emptied, nor are its elements removed in any other way. List.subList() doesn't remove any elements, it just returns a view of the list, but the original list remains intact.

Good luck!
11 years ago
This is essentially what's wrong: you're declaring a local variable with the same name as your class variable (NumberTable). The static block has its own scope just like methods do, so when you assign anything to it, your class variable won't be affected at all.

Good luck!
11 years ago
You should start at the inner-most method call:
When you call indexOf() on a String (in this case, "mail: [email protected]"), you get the index of the first occurrance of "mail: " in that string. Since "mail: " is at the beginning, indexOf() returns 0.

Then there's the next method call:
As you probably noticed, I replaced the call to indexOf() with the result to make it easier to read. Calling substring() on a String returns a part of that string. Since you're using the String.substring( int ) version of the method, you get the part of the string starting at index 6 (0+6 = 6). Let's see which part that is:
According to the code block above, substring() should return the string " [email protected]". Note that the extra whitespace is preserved at the beginning of the string.
11 years ago