Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

In one of my methods for Part II, Im getting a StringIndexOutOfBoundsException. What am I doing wrong?

0
Posted

In one of my methods for Part II, Im getting a StringIndexOutOfBoundsException. What am I doing wrong?

0

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

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.

Experts123