blob: 23d9fe58f7b73f86abc1c8613afddcbad993f988 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
|
public class Ch1 {
public static void main(String[] args) {
System.out.println(last_word("The Weekly Challenge"));
System.out.println(last_word(" Hello World "));
System.out.println(last_word("Let's begin the fun"));
}
private static int last_word(String s) {
String[] arr = s.trim().split(" ");
return arr[arr.length - 1].length();
}
}
|