-1

I want to remove space from the below string.

String name= "I n p u t   T e x t";

Can someone please suggest how to remove the spaces?

I have solution only to remove spaces between the string not between the char

user23050
  • 1
  • 1

1 Answers1

1

Try following:

String name= "I n p u t   T e x t";
String namenew = name.replaceAll("\\s+","");
System.out.println(name);
System.out.println(namenew);

Cheers !

Sachin Thapa
  • 3,559
  • 4
  • 24
  • 42