In one of my methods for Part II, Im getting a StringIndexOutOfBoundsException. What am I doing wrong?
Don’t forget that the characters in a string have index values that go from 0 to length – 1. The exception means that your code is using an index from outside that range. • Can the methods that we write for parts a-d of problem 4 read values from the console? No! Only your main method should read from the console. Then, when the main method calls your other methods, it should pass in the necessary strings as parameters so that the other methods can access them. • In lecture, we covered examples of methods that take a String as a parameter and return a value, but we didn’t cover one that takes a String as a parameter and doesn’t return anything — which is what we’re supposed to do in parts a and b of problem 4. Can you give us an example of such a method? Sure. Let’s say that we want a method called printVertical that takes a String as a parameter and prints it vertically — one character per line. For example, the method call printVertical(“hello”); should print the following: h e l l