| 1 | package leetcode; |
| 2 | |
| 3 | public class Lengthofword { |
| 4 | |
| 5 | public static void main(String[] args) { |
| 6 | String s= "Hello worldss"; |
| 7 | String s3=" "; |
| 8 | String s6 ="a "; |
| 9 | |
| 10 | System.out.println(s6.length()); |
| 11 | // trim() 바깥의 공백 잘라줌 |
| 12 | // lastIndexOf로 뒤에서 찾아주고 -> 왼쪽부터 셈 |
| 13 | // String a = s.substring(s.trim().lastIndexOf(" ")-1,s.trim().length()); |
| 14 | // System.out.println(a.trim().length()); |
| 15 | |
| 16 | |
| 17 | String str[] = s.split(" "); |
| 18 | |
| 19 | if(str.length == 0) { |
| 20 | System.out.println(0); |
| 21 | }else |
| 22 | System.out.println(str[str.length-1].length()); |
| 23 | |
| 24 | } |
| 25 | |
| 26 | } |
nothing calls this directly
no outgoing calls
no test coverage detected