Question: Write a method to search for the first occurrence of a character in a string. If you have the character in the string, you
Write a method to search for the first occurrence of a character in a string. If you have the character in the string, you should return it's index otherwise throw NoSuchElementException with an appropriate string parameter. The NoSuchElementException is in java.util package. Add proper JavaDoc comments and necessary inline comments. Make sure to test your method with a few test cases.
Step by Step Solution
There are 3 Steps involved in it
import javautilNoSuchElementException Searches for the first occurrence of a character in a string p... View full answer
Get step-by-step solutions from verified subject matter experts
