How do I change Eclipse to use spaces instead of tabs?

By default Eclipse indents with a hard tab character. How do I change it to spaces? 2Best Answer 21 Java Editor Click Window » Preferences Expand Java » Code Style Click Formatter Click the Edit button Click the Indentation tab Under General Settings, set Tab policy to: Spaces only Click OK ad nauseam to apply … Read more

Removing whitespace from strings in Java

st.replaceAll(“\\s+”,””) removes all whitespaces and non-visible characters (e.g., tab, \n). st.replaceAll(“\\s+”,””) and st.replaceAll(“\\s”,””) produce the same result. The second regex is 20% faster than the first one, but as the number consecutive spaces increases, the first one performs better than the second one. Assign the value to a variable, if not used directly: st = st.replaceAll(“\\s+”,””)