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.
A sonic boom would certainly ruin a giant souffle. But this tiny ad would protect it:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|