Remove blanks from a string and join it

Asked

Viewed 422 times

1

I have a string of a Logical Expression

Ex:

((T ∨ F → T) ∧ (T → F)) → (∼F → T)

I need to remove the blanks from the string and join them as a result:

((T∨F→T)∧(T→F))→(∼F→T)

How can I do this in Java? I tried using replaceAll("\\s",""); but I was unsuccessful.

  • 8

    Utilize string.replaceAll(" ", ""); or string.replaceAll("\\s", "");

  • 1

    You sure are spaces?

  • Strings are immutable in Java, so the method will generate a new variable. You are storing this new variable?

  • It ended up working, I believe it was some mistake of mine when creating the method, it worked with the string.replaceAll(" s", ""); thank you very much!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.