58. Length of Last Word
要是都是空格的话 返回的array长度就是0
1 class Solution { 2 public int lengthOfLastWord(String s) { 3 if(s.length() == 0 || s == null) return 0; 4 String[] str = s.split(" "); 5 if(str.length != 0) { 6 return str[str.length - 1].length(); 7 } 8 return 0; 9 10 } 11 }