@@ -0,0 +1,1146 @@
+package leetcode.length_of_last_word;%0A%0Apublic class Solution %7B%0A    public int lengthOfLastWord(String s) %7B%0A    %09if(s == null %7C%7C s.length() == 0) return 0;%0A    %09char%5B%5D chars = s.toCharArray();%0A    %09int endIdx = -1, startIdx = -1;%0A    %09for(int i = chars.length - 1; i %3E= 0; i--)%7B%0A    %09%09if(endIdx == -1)%7B%0A%09    %09%09if(chars%5Bi%5D != ' ')%7B%0A%09    %09%09%09endIdx = i; %0A%09    %09%09%7D%0A    %09%09%7Delse if(startIdx == -1)%7B%0A    %09%09%09if(chars%5Bi%5D == ' ')%7B%0A    %09%09%09%09startIdx = i;%0A    %09%09%09%09break;%0A    %09%09%09%7D%0A    %09%09%7D%0A    %09%7D%0A    %09return endIdx - startIdx;%0A    %7D%0A    %0A    public static void main(String%5B%5D args)%7B%0A    %09System.err.println(new Solution().lengthOfLastWord(%22hello%22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22hello %22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22 hello%22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22hello worlddd%22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22hello worlddd %22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22 hello worlddd%22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22 hello worlddd %22));%0A    %09System.err.println(new Solution().lengthOfLastWord(%22  %22));%0A    %7D%0A%7D%0A

Add java solution for 58. Length of Last Word