Yes, but do you see what happens if the user enters a String without a period? Let's see what happens when you enter "hi" without the quotes.Since 'h' is not a period, the loop body is executed, placing 'h' into the array a.Since 'i' is not a period, the loop body is executed, placing 'i' into the array a.Since i is now outside the bounds of legal values for the String, you get a StringIndexOutOfBoundsException.Originally posted by eric elysia:
I am trying to write code that makes sure the user does enter a period.
Yeah. What he said. Totally. Wait. What? Sorry, I was looking at this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
|