- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSample4.java
More file actions
Latest commit
18 lines (15 loc) · 476 Bytes
/
Copy pathSample4.java
File metadata and controls
18 lines (15 loc) · 476 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
publicclassSample4 {
publicstaticvoidprintLastChars(Stringstr) {
String[] arr = str.split(" ");
StringBuffernewStr = newStringBuffer();
for (Stringcur : arr) {
if (!cur.isBlank())
newStr.append(cur.charAt(cur.length() - 1));
}
System.out.println(newStr);
}
publicstaticvoidmain(String[] args) {
Stringstr = "Hello Welcome Java World";
printLastChars(str);
}
}