import java.util.*; class Ltrim { public static void main(String... S) { int count = 0; char ch; System.out.println("enter the line"); Scanner sc = new Scanner(System.in); String Str = sc.nextLine(); for(int i=0;i<Str.length();i++) { ch = Str.charAt(i); if(ch ==' ' && count == 0) { } else { count = 1; System.out.print(ch); } } } }
String strValue ="abcd efgh"; strValue = strValue.trim(); strValue = strValue.replaceAll(" ", ""); System.out.println("length " + strValue.length());
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)