/* * 58. Length of Last Word * 2016-5-7 by Mingyang 注意split中以“ ”才是空格 */ public static int lengthOfLastWord(String s) { if (s == null || s.length() == 0) return 0; s = s.trim(); String[] cou = s.split(" "); int len = cou.length; String tempStr = cou[len - 1]; return tempStr.length(); }