Solution
Since your class contains static methods only (according to your question, the class has one static method ), the class must have “static” modifier, since it cannot be instantiated. Only classes with at least one not static method can be instantiated. The rule is valid for both: Java and C#.
So, I would suggest to rewrite this piece of code as follows:
public static class Helper{
public static String invertirPalabras(String cadena) {
cadena += " ";
String palabra = "";
String nuevaCadena = "";
for (int i = 0; i < cadena.length(); i++) {
palabra = cadena.charAt(i) + palabra;
if (cadena.charAt(i) == ' ') {
nuevaCadena += palabra;
palabra = "";
}
}
return nuevaCadena.trim();
}
}