NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
Given a string s consists of upper/lower-case alphabets and empty space characters ’ ‘, return the length of last word in the string. If the last word does not exist, return 0. ~~~ public class Solution { public int lengthOfLastWord(String s) { String [] sp = s.split(" "); //for(int i=sp.length;i>=0;i--){ for(int i=sp.length-1;i>=0;i--){ if(sp[i].length()>0) return sp[i].length(); } return 0; } } ~~~