Skip to content

Commit ac1ebf8

Browse files
committed
Split
lastword lastWord.length();
1 parent 3648ab9 commit ac1ebf8

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

LengthOfLastWord.java

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public class LengthOfLastWord
2+
{
3+
public static void main(String[] args)
4+
{
5+
System.out.println(lengthOf("Aditya Parihar"));
6+
}
7+
static int lengthOf(String s)
8+
{
9+
s.trim();
10+
11+
String[] str = s.split(" ");
12+
13+
String lastWord = str[str.length-1];
14+
15+
return lastWord.length();
16+
}
17+
}

0 commit comments

Comments
 (0)