If there is any way to refine it, please reply to me. I really appreciate it.

```
public int lengthOfLastWord(String s) {
boolean find = false;
int length =0;
int i =0,j =0;
for(;i<s.length();i++){
if(s.charAt(i)!=' '&&!find){
j = i;
find = true;
}
if(s.charAt(i)==' '&&find){
length = i -j;
find = false;
}
}
if(find){
return i -j;
}else{
return length;
}
}
```