Hey guys
This is probably a very simple question, but i can’t seem to get the just of it.
String sentence = “Hello\nWorld”;
now i want to remove the last line of the string ("\nWorld");
i.e. sentence -= "\n"
but then it says
"operator - cannot be applied to java.lang.String,java.lang.String"
I somewhat disagree with the previous answer. You could combine indexOf() and substring() but I think split() is much better suited since you will get a String[] array containing all the parts you were after.
Naturally this heavily depends on what the final goals are but since that wasn’t included…