I am new to Java, and I'm currently writing a program that uses arguments using the entered arguments to delimit the text file containing sentences, and then determines the number of sentences in this text file based on the provided delimiters.
When starting my Main.java, I want the user to be able to do the following (where -d is the flag for the separator, and the following characters are the separators):
java Main -d!?. or java Main -d.?
Or any other combination. My questions:
- Best way to store delimiters as strings or arrays?
- How can I say that my program uses transmittable delimiters? Currently, my program does the following:
Checks if a word ends with any of the specified delimiters. For instance:
if (word.endsWith(".") || word.endsWith("!") || word.endsWith("?")) { sentenceCount++ }
But instead, I would like it to be something like:
if (word.endsWith(delimitersStringorArray.contains()) { sentenceCount++ }
I hope this makes sense, and I can provide any further clarifications if necessary. I tried searching, but did not find my specific question.
Thanks!
Bryce source share