public static int lengthOfLastWord(String s) {
if(s == null || s.length() == 0) {
return 0;
}
String[] str= s.split(" ");
int i = 0;
int len = 0;
for(i = str.length - 1; i >=0; i--) {
if(str[i].length() > 0) {
len = str[i].length();
break;
}
}
return len;
}