I am separating a word in Java whose separator is a -, my problem comes in that sometimes it does not have - to separate and therefore it gives me an error, as I could previously detect that the separator does not exist. An example to be understood: That is, it works correctly
String palabra="hola-adios";
But if I pass through the Split a string without a separator like the following, there is an exception:
String palabra2="hola";