Skip to content
Advertisement

Java .split method returning empty array

I am trying to count all the words in each sentence in an array of multiple sentences automatically from a file in eclipse.

When I’m splitting the paragraph into sentences the java .split method is returning an empty array

Here is the code that is causing me trouble

JavaScript

here is my sentence class

JavaScript

And finally, here is my text file (it is only one line of text)

JavaScript

Here is the output

JavaScript

Advertisement

Answer

Replace paragraph.split(".") by paragraph.split("\.")

Advertisement