30 November 2012

code to check if the string contains all digits or not

Long checkDataType(String s){

char c[]=s.toCharArray();
boolean isnum=true;

for(int i=0;i
     if(!Character.isDigit(c[i])){

    isnum=false;

    break;

  }

}

if(isnum)

return (Long.parseLong(s));

else

return null;

}




Delicious add to del.icio.us saved by 0 users

No comments:

Post a Comment