牛客华为机试题库【题号 HJ开头】(重点看)
牛客在线编程算法篇【题号NC开头】
剑指offer【题号 JZ开头】
力扣
1)原题链接
2)已有题解
3)代码
package string;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import static java.lang.System.in;
public class HJ1TheLengthOfTheLastWordInTheString {
public static void main(String[] args) throws IOException {
BufferedReader bf = new BufferedReader(new InputStreamReader(in));
String str = bf.readLine();
bf.close();
List<String> words = Arrays.stream(str.split(" ")).collect(Collectors.toList());
String s = words.get(words.size() - 1);
System.out.println(s.length());
}
}