件名:https : //leetcode-cn.com/problems/length-of-last-word/
回答:
public int lengthOfLastWord(String s){
s = s.trim();
int index = s.lastIndexOf( "");
if(index <0){
s.length();を返します。
}そうしないと{
s.length()-index-1を返します。
}
}
件名:https : //leetcode-cn.com/problems/length-of-last-word/
回答:
public int lengthOfLastWord(String s){
s = s.trim();
int index = s.lastIndexOf( "");
if(index <0){
s.length();を返します。
}そうしないと{
s.length()-index-1を返します。
}
}