Wednesday, 27 August 2014

Trim the left side of the String

class StringDemo6
{
static String LTrim(String s)
{
String c = "";
int i=0;
while( s.charAt(i) == ' ' )
{
i++;
}
while(i<s.length())
{
c += s.charAt(i);
i++;
}
return c;
}
public static void main(String... s)
{
System.out.println(LTrim("    i am an indian"));
}
}

No comments: