TechFundu

  • Increase font size
  • Default font size
  • Decrease font size
Welcome Guest,  Login | Join Now
Home Groups Core Java Developers Discussions Remove leading zeros from string
Remove leading zeros from string
Discussion started by roselin , on 03 August 06:29 AM
How to remove leading Zeros from a string in java ?
Replies
You will need to be a member of this group first before you can post a reply.
Deepa Mehta
public static String removeLeadingZeros(String str)
{
if (str == null)
{
return null;
}
char[] chars = str.toCharArray();
int index = 0;
for (; index < str.length();index++)
{
if (chars[index] != '0')
{
break;
}
}
return (index == 0) ? str :str.substring(index);
}
Monday, 03 August 2009 06:30
 

TechFundu Polls

Which is the best Javascript framework in your opinion?

Follow us on Twitter